Error in max function
Ältere Kommentare anzeigen
Why do I get this error?
>> MAX
a =
2 3 5
Index exceeds the number of array elements (1).
Error in MAX (line 2)
b = max(a)
I get the same kind of error when I dot this:
g1 = input('Give a number: ')
g2 = input('Give another number: ')
gg = max([g1,g2])
3 Kommentare
Andrei Bobrov
am 15 Jan. 2020
Bearbeitet: Andrei Bobrov
am 15 Jan. 2020
On my desktop:
>> g1 = input('Give a number: ');
g2 = input('Give another number: ');
gg = max([g1,g2])
Give a number: 45
Give another number: 78
gg =
78
>>
And what is it 'MAX'?
WalterWhite
am 15 Jan. 2020
Both of the above mentioned codes are functioning properly without any error as they are supposed to
a = [2 3 5]
a =
2 3 5
>> b = max(a)
b =
5
>> reading
Give a number: 3
g1 =
3
Give another number: 99
g2 =
99
gg =
99
Ellen De Jonghe
am 15 Jan. 2020
Antworten (1)
Walter Roberson
am 15 Jan. 2020
3 Stimmen
You accidentally defined a variable with the name max.
1 Kommentar
Andrei Bobrov
am 15 Jan. 2020
+1
Kategorien
Mehr zu Startup and Shutdown finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!