Info

この質問は閉じられています。 編集または回答するには再度開いてください。

how to pass the vector "TCP_value" in to the function

1 回表示 (過去 30 日間)
Satabdi Palit
Satabdi Palit 2018 年 4 月 24 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
function [ ] = GRADE(TCP_value) for i=1:25 if TCP_value >=6.5 disp('A+') elseif TCP_value >=6.0 disp('A') elseif TCP_value>=5.5 disp('B') elseif TCP_value>=5.0 disp('C') elseif TCP_value>=4.5 disp('D') elseif TCP_value>=4.0 disp('E') else disp('F') end
end
end

回答 (1 件)

Are Mjaavatten
Are Mjaavatten 2018 年 4 月 24 日
編集済み: Are Mjaavatten 2018 年 4 月 24 日
In your test you must compare element no, i in the TCP_value array with the limits:
function GRADE(TCP_value)
for i=1:length(TCP_value)
if TCP_value(i) >=6.5
fprintf('No.: %2d Grade: %-2s\n',i,'A+')
elseif TCP_value(i) >=6.0
fprintf('No.: %2d Grade: %-2s\n',i,'A')
... and so on ...
end
end
end
Note the use of length(TCP_value) in the loop. This gives more flexibility if the number of candidates vary. I also display the candidate number, to make the list easier to interpret.

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by