Function handle with inputs

13 ビュー (過去 30 日間)
Jay
Jay 2020 年 4 月 13 日
編集済み: Mehmed Saad 2020 年 4 月 13 日
% When I input W(3) IN THE COMMAND LINE (without any input for ii), there is an output for W?
% Why is that?
m = 3;
L = 10;
R = 1;
r = R/(m+1);
S = sqrt(2);
s = S/(m+1);
d1 = 1;
d2 = 0.25;
gama = atan(R/d1);
phi_i = @(ii, m) atan( (d1 + (ii*d2)./(m+1))./(r/3) );
W = @(m) ( r + s*sum(sin(gama + pi/2 - phi_i(1:m, m))) );

回答 (1 件)

Mehmed Saad
Mehmed Saad 2020 年 4 月 13 日
編集済み: Mehmed Saad 2020 年 4 月 13 日
You input phi_i in function W as follow
ii = 1:m;
m = m;
Now you feed input W function a value (m), suppose 3
the function phi_i gets following
phi_i(1:3,3)
So that's why you will get value when executing W(3)
On the other hand
This will not give you output until you provide ii value in your workspace
W = @(m) ( r + s*sum(sin(gama + pi/2 - phi_i(ii, m))) );

カテゴリ

Help Center および File ExchangeFunctions についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by