error with results, matlab
Mostra commenti meno recenti
Where is error? My program showed my only WYKRYTO, but I don't know what.
fprintf('\nWYKRYTO: ');
if (kaszel == max([kaszel, smiech, krzyk, chrzakanie]))
fprintf('kaszel');
elseif (smiech == max([kaszel, smiech, krzyk, chrzakanie]))
fprintf('smiech');
elseif (krzyk == max([kaszel, smiech, krzyk, chrzakanie]))
fprintf('krzyk');
elseif (chrzakanie == max([kaszel, smiech, krzyk, chrzakanie]))
fprintf('chrzakanie');
end
13 Commenti
Matt J
il 21 Gen 2014
Works fine for me.
AJ von Alt
il 21 Gen 2014
What are the values of kaszel, smiech, krzyk, and chrzakanie ?
Your programs seems to work properly when I set them to random values.
You should also add a fprintf('\n') after end to improve readability.
Monika
il 21 Gen 2014
Walter Roberson
il 21 Gen 2014
Are they strings?
Patrik Ek
il 21 Gen 2014
Is the code in your script identical with the code in the question? Including new lines and so? In that case you need to add 3 dots after each comma where you start writing on next line. Otherwise MATLAB assumes a matrix
[1 2 3; 4]
Which have wrong dimensions.
Walter Roberson
il 21 Gen 2014
What is class(kaszel) ?
Monika
il 21 Gen 2014
Walter Roberson
il 21 Gen 2014
What is class(kaszel) ? Run your program and at the end of that section
disp(class(kaszel))
and tell us what the output was.
Monika
il 21 Gen 2014
Walter Roberson
il 21 Gen 2014
Please show
size(kaszel), size(smiech), size(krzyk), size(chrzakenie)
Monika
il 21 Gen 2014
Modificato: Walter Roberson
il 21 Gen 2014
Monika
il 21 Gen 2014
Modificato: Walter Roberson
il 22 Gen 2014
Risposta accettata
Più risposte (2)
Azzi Abdelmalek
il 21 Gen 2014
Maybe you want
fprintf('\\nWYKRYTO: ');
3 Commenti
Monika
il 21 Gen 2014
Azzi Abdelmalek
il 21 Gen 2014
If you give some data we can test your code.
Monika
il 21 Gen 2014
Modificato: Walter Roberson
il 21 Gen 2014
per isakson
il 21 Gen 2014
0 voti
2 Commenti
Matt J
il 21 Gen 2014
Hard to imagine that applies to max() operations. I'm not encountering issues, at least.
per isakson
il 22 Gen 2014
Modificato: per isakson
il 22 Gen 2014
Agree, but it's a good habit not to use "==" with floats.
Categorie
Scopri di più su MATLAB in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
