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

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

 Respuesta aceptada

Walter Roberson
Walter Roberson el 1 de Sept. de 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'

Más respuestas (0)

Categorías

Más información sobre Operators and Elementary Operations en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 1 de Sept. de 2020

Comentada:

el 1 de Sept. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by