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!
