Hi everyone.
I want to make a function that takes three vectors and uses them as the variables (for an example)
f([a1,a2],[x0,y0,z0], [d1,d2]) = (a1*a2)/(x0+y0)*(z0+d1+d2).^2
How should I code this in MATLAB?
Thanks in advance! Maja

 採用された回答

Torsten
Torsten 2018 年 2 月 2 日
編集済み: Torsten 2018 年 2 月 2 日

1 投票

function result = f(a,x,d)
result = a(1)*a(2)/(x(1)+x(2))*(x(3)+d(1)+d(2))^2;
or simply
f=@(a,x,d)a(1)*a(2)/(x(1)+x(2))*(x(3)+d(1)+d(2))^2;
Best wishes
Torsten.

その他の回答 (0 件)

カテゴリ

質問済み:

2018 年 2 月 2 日

編集済み:

2018 年 2 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by