error with results, matlab
Afficher commentaires plus anciens
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 commentaires
Matt J
le 21 Jan 2014
Works fine for me.
AJ von Alt
le 21 Jan 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
le 21 Jan 2014
Walter Roberson
le 21 Jan 2014
Are they strings?
Patrik Ek
le 21 Jan 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
le 21 Jan 2014
What is class(kaszel) ?
Monika
le 21 Jan 2014
Walter Roberson
le 21 Jan 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
le 21 Jan 2014
Walter Roberson
le 21 Jan 2014
Please show
size(kaszel), size(smiech), size(krzyk), size(chrzakenie)
Monika
le 21 Jan 2014
Modifié(e) : Walter Roberson
le 21 Jan 2014
Monika
le 21 Jan 2014
Modifié(e) : Walter Roberson
le 22 Jan 2014
Réponse acceptée
Plus de réponses (2)
Azzi Abdelmalek
le 21 Jan 2014
Maybe you want
fprintf('\\nWYKRYTO: ');
3 commentaires
Monika
le 21 Jan 2014
Azzi Abdelmalek
le 21 Jan 2014
If you give some data we can test your code.
Monika
le 21 Jan 2014
Modifié(e) : Walter Roberson
le 21 Jan 2014
per isakson
le 21 Jan 2014
0 votes
2 commentaires
Matt J
le 21 Jan 2014
Hard to imagine that applies to max() operations. I'm not encountering issues, at least.
per isakson
le 22 Jan 2014
Modifié(e) : per isakson
le 22 Jan 2014
Agree, but it's a good habit not to use "==" with floats.
Catégories
En savoir plus sur MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
