Matlab programming dealing with matrix -
i trying out 1 of matlab programming question.
question:
write function called hulk takes row vector v input , returns matrix h first column consist of elements of v, second column consists of squares of elements of v, , third column consists of cubes of elements v. example, if call function likes this, = hulk(1:3) , [ 1 1 1; 2 4 8; 3 9 27 ].
my code:
function h = hulk(v) h = [v; v.^2; v.^3]; size(h) = (n,3); end when test code using a = hulk(1:3), throws error on console.
your function made error argument(s) 0 am doing incorrect? have missed anything?
remove line size(h) = (n,3); , add line h = h';
total code should follows
function h = hulk(v) h = [v; v.^2; v.^3]; h = h'; end your code giving error in matlab editor on size(h) = (n,3); line 
that's why should use matlabeditor
Comments
Post a Comment