how can i pass a vector to a function?

7 Ansichten (letzte 30 Tage)
anu vru
anu vru am 8 Feb. 2018
Kommentiert: Ziyu Xu am 23 Okt. 2019
i have a function which has 2 variables each of these variables are a vector. how do i pass vector inputs to the function???

Akzeptierte Antwort

Birdman
Birdman am 8 Feb. 2018
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]

Weitere Antworten (0)

Kategorien

Mehr zu Surfaces, Volumes, and Polygons finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by