필터 지우기
필터 지우기

error with results, matlab

조회 수: 3 (최근 30일)
Monika
Monika 2014년 1월 21일
댓글: Monika 2014년 1월 22일
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
Monika
Monika 2014년 1월 21일
편집: Walter Roberson 2014년 1월 21일
Size of my signal is depends on which signal will be my input. I have 64 signals. I can make 64 different inputs.
>> disp(class(kaszel))
double
>> size(kaszel)
ans =
107 13
>> size(smiech)
ans =
107 13
>> size(krzyk)
ans =
107 13
>> , size(chrzakanie)
ans =
107 13
Monika
Monika 2014년 1월 21일
편집: Walter Roberson 2014년 1월 22일
My teacher told me, that I can the above code I can write in two lines.
[junk classID(i)] = max([sum(kaszel)
acc = sum(classID==labels)/length(labels)
But I don't know, how I should use acc

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2014년 1월 21일
max([array1, array2])
means
max(horzcat(array1, array2))
which in turn means
max(horzcat(array1, array2), [], 1)
which will calculate the column-by-column maximum of horzcat(array1, array2), which is going to give you a result which is 1 x (size(array1,2) + size(array2,2)) .
And then you try to compare the entire array array1 to the result of the max(), so you are comparing
size(array1,1) x size(array1,2)
to
1 x (size(array1,2) + size(array2,2))
and you can see by examination that the only way that can work is if array1 only has a single row and array2 is empty. (Well, that case would be treated differently by MATLAB, but you would still end up with mismatched lengths for the comparison)
Taking into account that you have entire arrays to be compared, what do you want your output to be? A 2D cell array of strings that indicates at each location which of the four arrays was the maximum at that point ? Or do you wish to know which of the four has the greatest average magnitude? Or something else?
  댓글 수: 9
Walter Roberson
Walter Roberson 2014년 1월 22일
Please show your current code fragment.
Monika
Monika 2014년 1월 22일
fprintf('\nObliczone wartości prawdopodobieństwa przynależenia do poszczególnych klas:\n');
fprintf('Kaszel: %d\nŚmiech: %d\nKrzyk: %d\nChrząkanie: %d\n',kaszel,smiech,krzyk,chrzakanie);
fprintf('\nProbka: %s',pliki(numer_pliku).klasa);
wavplay(sygnal,Fs);
fprintf('\nWYKRYTO: ');
T = cat(3, kaszel, smiech, krzyk, chrzakanie);
[maxval, IDs] = max(T, [], 3);
accumarray(IDs(:), 1)
fprintf('\n======================================================================');
end
fprintf('Zakończono działania skryptu\n');
else
fprintf('Niewystarczająca liczba próbek aby wyznaczyć GMM!');
fprintf('\nNaciśnij dowolny klawisz, aby kontynuować...');
pause;
rozpoznawanie_dzwiekow;
end

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Azzi Abdelmalek
Azzi Abdelmalek 2014년 1월 21일
Maybe you want
fprintf('\\nWYKRYTO: ');
  댓글 수: 3
Azzi Abdelmalek
Azzi Abdelmalek 2014년 1월 21일
If you give some data we can test your code.
Monika
Monika 2014년 1월 21일
편집: Walter Roberson 2014년 1월 21일

댓글을 달려면 로그인하십시오.


per isakson
per isakson 2014년 1월 21일
  댓글 수: 2
Matt J
Matt J 2014년 1월 21일
Hard to imagine that applies to max() operations. I'm not encountering issues, at least.
per isakson
per isakson 2014년 1월 22일
편집: per isakson 2014년 1월 22일
Agree, but it's a good habit not to use "==" with floats.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by