Real cepstrum in loop
Show older comments
Hi
I have to compute a real cepstrum of .wav signal taking 20ms parts of signal, skip 5ms. Next I have to plot this in 3D using imagesc and mesh. My problem is in loop when I run rceps function.
My code is
[x,fp]=wavread('name_of_file.wav');
dr=4; %decimation level
fd=fp/dr;
y=decimate(x,dr);
Nd=length(y); %length of decimated signal
t=0:1/fd:(Nd-1)/fd;
next
d=floor(( ( ( ( (Nd-1) /fd) *1000) -20) /5)); %number of 20ms parts with skip
5ms
for i=0:1:d
g=y( ( ( ( ((i*5) +1) /1000) *fd):( ( ( ((i*5) +21) /1000) *fd) );
%g=y(((i*60)+1):((i*60)+240)); %another method of cutting signal
tab(i+1)=rceps(g);
end
After running this code I see an error
??? In an assignment A(I) = B, the number of elements in B and
I must be the same.
Error in ==> my_file at 38
tab(i)=rceps(g);
rceps function return real cepstrum of signal. Length of returning signal is the same as argument signal (in my case 20ms, 240 points).
I don't have enough experience to solve this problem, because this is my first time when I use loop in MATLAB and I don't know how to do this correctly.
Thank you for your time
Dawid
Accepted Answer
More Answers (1)
David Young
on 26 Dec 2011
Your receps function returns a vector with 240 elements, and you are trying to assign these to a single element of tab. The error message is telling you that you can't put 240 numbers into a slot that only holds one.
Try assigning the vector to a row of tab rather than to a single element, like this:
tab(i+1, :) = rceps(g);
2 Comments
Dawid
on 26 Dec 2011
David Young
on 27 Dec 2011
Could you have a look at the size of the result returned by receps:
r = receps(g);
disp(size(r));
Categories
Find more on Cepstral Analysis in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!