Wondering how to use the min/max function in an array?

3 views (last 30 days)
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

Accepted Answer

Walter Roberson
Walter Roberson on 1 Sep 2020
You are using the 's' option for input(). That means that you want characters back instead of numbers. 49 corresponds to the character '7'

More Answers (0)

Categories

Find more on Operators and Elementary Operations in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!