MATLAB Answers

How to play Audio File

3 views (last 30 days)
A= testing;
B= [ten;
twenty;
fifty;
hundered;
fivehundered;
thousand];
G={'ten';
'twenty';
'fifty';
'hundered';
'five_hundered';
'thousand'};
class=knnclassify(A,B,G);
disp(class);
pathss=class
for index = 1:numel(pathss)
temp=pathss{index}
end
% [rows]=testing;
% for i=1:rows
if (temp=='ten')
a=wavread('stopsign.wav');
wavplay(a,44100);
% end
% end
% TF=strcmp(temp,ten)
% for index = 1:numel(pathss)
% temp1=pathss{index}
%
elseif (temp=='twenty')
a=wavread('crossroad.wav');
wavplay(a,44100);
elseif (temp=='fifty')
a=wavread('crossroad.wav');
wavplay(a,44100);
elseif (temp=='hundered')
a=wavread('crossroad.wav');
wavplay(a,44100);
elseif (temp=='five_hundered')
a=wavread('crossroad.wav');
wavplay(a,44100);
elseif (temp=='thousand')
a=wavread('crossroad.wav');
wavplay(a,44100);
end
end
This is a knnclassifer which i am using.It gets classifed into correct group but the audio file doesnt play.Whats the problem in here?

Accepted Answer

Walter Roberson
Walter Roberson on 4 Jun 2015
You should not be using "==" to compare strings. You should be using strcmp()
  3 Comments
B.k Sumedha
B.k Sumedha on 8 Jun 2015
Thanks Walter:).. Well i used the strcmp and it gave me the output.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!