Matlab Code for substituting numbers in variable matrix

53 Views Asked by At

In Matlab, if we input a number matrix say [1 2; 3 4; 5 6], then what should i do so that the output would be of the form $ [(x_i-z)^b \hspace{5mm} y_i]$ where $z$ and $b$ are just variables. Please help me with a code. i want that the data will be substituted to $x_i$'s and $y_i$'s.

2

There are 2 best solutions below

0
On

I don't have MATLAB on this machine so I can't test but I'm pretty sure you want the following:

mat = [1 2; 3 4; 5 6];
out = [ (mat(:,1) - z).^b mat(:,2)]

Let me know if that helps

0
On

Alternatively:

    A = [1 2; 3 4; 5 6];
    A(:,1) = (A(:,1) - z).^b;