Filter löschen
Filter löschen

Help with "matrix dimensions must agree".

2 Ansichten (letzte 30 Tage)
Kyle Reagan
Kyle Reagan am 4 Dez. 2016
Kommentiert: Star Strider am 4 Dez. 2016
In my code I have an input that says answer = input('Please type "yes" or no".','s'); if answer == 'yes' blah blah else disp('Error, please make sure a file is uploaded.') end
For some reason when I enter "no", there is a problem where it says "Error. Matrix dimensions don't agree." But when i enter "n" it gives me my custom error statement for the else condition.
  1 Kommentar
Kyle Reagan
Kyle Reagan am 4 Dez. 2016
if true
% answer = input('Has a file been uploaded? Answer "yes" or "no" in the command window. \n','s');
if answer == 'yes'
figure
histogram(file)
else
disp('Error. Something went wrong. Please exit program and try again. \n')
end
end

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Star Strider
Star Strider am 4 Dez. 2016
Change the if condition to:
if strcmp(answer, 'yes')
  2 Kommentare
Kyle Reagan
Kyle Reagan am 4 Dez. 2016
Thanks, works like a charm!
Star Strider
Star Strider am 4 Dez. 2016
My pleasure!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Entering Commands finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by