error with results, matlab
显示 更早的评论
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 个评论
Matt J
2014-1-21
Works fine for me.
AJ von Alt
2014-1-21
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
2014-1-21
Walter Roberson
2014-1-21
Are they strings?
Patrik Ek
2014-1-21
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
2014-1-21
What is class(kaszel) ?
Monika
2014-1-21
Walter Roberson
2014-1-21
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
2014-1-21
Walter Roberson
2014-1-21
Please show
size(kaszel), size(smiech), size(krzyk), size(chrzakenie)
Monika
2014-1-21
编辑:Walter Roberson
2014-1-21
Monika
2014-1-21
编辑:Walter Roberson
2014-1-22
采纳的回答
更多回答(2 个)
Azzi Abdelmalek
2014-1-21
Maybe you want
fprintf('\\nWYKRYTO: ');
3 个评论
Monika
2014-1-21
Azzi Abdelmalek
2014-1-21
If you give some data we can test your code.
Monika
2014-1-21
编辑:Walter Roberson
2014-1-21
per isakson
2014-1-21
0 个投票
2 个评论
Matt J
2014-1-21
Hard to imagine that applies to max() operations. I'm not encountering issues, at least.
per isakson
2014-1-22
编辑:per isakson
2014-1-22
Agree, but it's a good habit not to use "==" with floats.
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
