Wondering how to use the min/max function in an array?
3 ビュー (過去 30 日間)
古いコメントを表示
a = input('What is a?','s');
b = input('What is b?','s');
c = input('What is c?','s');
d = input('What is d?','s');
Lengths = [ a b c d ];
S = min(Lengths)
L = max(Lengths)
PQ = sum(Lengths) - (S + L)
if S + L < PQ
Condition = 'Grashof'
elseif S + L == PQ
Condition = 'Special Grashof'
elseif S + L > PQ
Condition = 'Non-Grashof'
end
Whenever I input this, for a=7, b=11, c=8, and d=9, it gives me that S=49 and L=57. I want S=7 and L=11
0 件のコメント
採用された回答
Walter Roberson
2020 年 9 月 1 日
You are using the 's' option for input(). That means that you want characters back instead of numbers. 49 corresponds to the character '7'
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Operators and Elementary Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!