how can i pass a vector to a function?

i have a function which has 2 variables each of these variables are a vector. how do i pass vector inputs to the function???

 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]

More Answers (0)

Asked:

on 8 Feb 2018

Commented:

on 23 Oct 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!