MATLAB Answers

anu vru
0

how can i pass a vector to a function?

Asked by anu vru
on 8 Feb 2018
Latest activity Answered by Birdman
on 8 Feb 2018
i have a function which has 2 variables each of these variables are a vector. how do i pass vector inputs to the function???

  0 Comments

Sign in to comment.

1 Answer

Answer by Birdman
on 8 Feb 2018
 Accepted Answer

function z=f(x,y)
z=x.^2+y.^2;
end
From command line, type
x=[1;2];y=[3;4]
z=f(x,y)
and the result would be
[10;20]

  0 Comments

Sign in to comment.