how can i pass a vector to a function?

7 ビュー (過去 30 日間)
anu vru
anu vru 2018 年 2 月 8 日
コメント済み: Ziyu Xu 2019 年 10 月 23 日
i have a function which has 2 variables each of these variables are a vector. how do i pass vector inputs to the function???

採用された回答

Birdman
Birdman 2018 年 2 月 8 日
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]
  1 件のコメント
Ziyu Xu
Ziyu Xu 2019 年 10 月 23 日
OMG, you just saved my life!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurfaces, Volumes, and Polygons についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by