plot based on if and else condition
4 次查看(过去 30 天)
显示 更早的评论
GoodEvening Sir/Mam,
I'm working in intesity of speech .I have classified it based om maximum to minimum energy but i dont know how to plot them.Please help me as possible
[x,fs] = audioread("sa.wav");
%end
si = 0.020;Fsi=si*fs;t=(0:1/Fsi);
frames=framing(x,fs,Fsi);
[r,c] = size(frames);
signal = zeros(size(0));
for i = 1:r
signal(i) = sum(frames(i,:).^2);
end
A=zeros(1,length(signal));
B=zeros(1,length(signal));
C=zeros(1,length(signal));
D=zeros(1,length(signal));
sig = max(signal);
for j=1:length(signal)
I(j)=(signal(j)/sig);
if(0.9<=I(j)<=1)
A(j)=I(j);
plot(A,'b-');hold on
elseif(0.6<=I(j)<=0.8)
A(j)=I(j);
plot(A,'b-');hold on
elseif(0.4<I(j)<=0.6)
A(j)=I(j);
plot(A,'b-');hold on
elseif(0.2<=I(j)<=0.5)
A(j)=I(j);
plot(A,'b-');hold on
elseif(0<=I(j)<=0.1)
A(j)=I(j);
plot(A,'b-');hold on
end
end
0 个评论
回答(4 个)
Torsten
2022-8-14
MATLAB does not accept "double inequalities".
Thus instead of
if a < b < c
you will have to use
if a < b && b < c
Further, you should plot A completely after the if-clause, not after every value of j.
Further, you missed to classify the cases 0.8 < l(j) < 0.9, 0.4 < l(j) < 0.5 and 0.1 < l(j) < 0.2. Or should A remain 0 in these cases ?
3 个评论
Malar Vizhi
2022-8-14
1 个评论
Torsten
2022-8-14
Yes, A is the signal, normalized to 1.
What else do you expect for the plot if you set
A = signal/max(signal)
(because this is what you do) ?
Malar Vizhi
2022-8-16
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Octave 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!