error with results, matlab
Show older comments
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 Comments
Matt J
on 21 Jan 2014
Works fine for me.
AJ von Alt
on 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
on 21 Jan 2014
Walter Roberson
on 21 Jan 2014
Are they strings?
Patrik Ek
on 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
on 21 Jan 2014
What is class(kaszel) ?
Monika
on 21 Jan 2014
Walter Roberson
on 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
on 21 Jan 2014
Walter Roberson
on 21 Jan 2014
Please show
size(kaszel), size(smiech), size(krzyk), size(chrzakenie)
Monika
on 21 Jan 2014
Edited: Walter Roberson
on 21 Jan 2014
Monika
on 21 Jan 2014
Edited: Walter Roberson
on 22 Jan 2014
Accepted Answer
More Answers (2)
Azzi Abdelmalek
on 21 Jan 2014
Maybe you want
fprintf('\\nWYKRYTO: ');
3 Comments
Monika
on 21 Jan 2014
Azzi Abdelmalek
on 21 Jan 2014
If you give some data we can test your code.
Monika
on 21 Jan 2014
Edited: Walter Roberson
on 21 Jan 2014
per isakson
on 21 Jan 2014
0 votes
2 Comments
Matt J
on 21 Jan 2014
Hard to imagine that applies to max() operations. I'm not encountering issues, at least.
per isakson
on 22 Jan 2014
Edited: per isakson
on 22 Jan 2014
Agree, but it's a good habit not to use "==" with floats.
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!