フィルターのクリア

Code Error Help Please

1 回表示 (過去 30 日間)
Az Naqvi
Az Naqvi 2021 年 8 月 6 日
回答済み: Image Analyst 2021 年 8 月 6 日
Hello I have the following code andI've been trying to get it to work but haven't been able to. Could someone please help?
Sorry if this is an easy question I'm new to matlab.
function y=f(Fm,alf,bet,dist_a,dist_b)
y=[-1,sind(alf),cosd(bet);
0,cosd(alf),cosd(bet);
0,0,(dist_a+dist_b)*cosd(bet)][0;1;dist_a]*Fm;
disp('FCE, FCA, FDB')
disp(y')
endfunction
disp('2a-Part 1')
f(-500,30,45,5,5);
disp('2a-Part 2')
f(-281,20,58,5,5);
disp('2b-Part 1')
f(-500,30,45,5,3.72);
disp('2b-Part 2')
f(-281,20,58,5,6.28);
Thank you in advance

回答 (2 件)

Chunru
Chunru 2021 年 8 月 6 日
disp('2a-Part 1')
2a-Part 1
f(-500,30,45,5,5);
FCE, FCA, FDB 1.0e+04 * -0.2018 -0.2201 -1.7678
disp('2a-Part 2')
2a-Part 2
f(-281,20,58,5,5);
FCE, FCA, FDB 1.0e+03 * -0.8406 -1.0086 -7.4454
disp('2b-Part 1')
2b-Part 1
f(-500,30,45,5,3.72);
FCE, FCA, FDB 1.0e+04 * -0.2018 -0.2201 -1.5415
disp('2b-Part 2')
2b-Part 2
f(-281,20,58,5,6.28);
FCE, FCA, FDB 1.0e+03 * -0.8406 -1.0086 -8.3984
% function here
function y=f(Fm,alf,bet,dist_a,dist_b)
y=[-1,sind(alf),cosd(bet);
0,cosd(alf),cosd(bet);
0,0,(dist_a+dist_b)*cosd(bet)]*[0;1;dist_a]*Fm; % * needed
disp('FCE, FCA, FDB')
disp(y')
end %function

Image Analyst
Image Analyst 2021 年 8 月 6 日
The problem is there is no "endfunction" statement in MATLAB. That will cause an error. It's just
end
Also, the script part must come before the function declaration if you have them both in the same file.
Try that. If it still doesn't work, tell us how you called the function including what values the input arguments had, and the exact error message (ALL the red text) after you read this link.

カテゴリ

Help Center および File ExchangeAdding custom doc についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by