lpc function for smaller intervals

조회 수: 2 (최근 30일)
micpro
micpro 2016년 11월 17일
댓글: Greg Dionne 2016년 11월 18일
Hi, I use lpc (linear predictive coding) in Matlab 2011a, a=lpc(W,p) then I get the formants from there (W is my signal and p is order), it returns me formant values.
But I want to get formants for smaller ranges of signal (not from all signal), For example, length(W)=1000, I want to research it's formants for
from i=0 to i=50 of W(i), then
i=51 to i=100, etc.
And getting 3 or 4 formant for each interval, When I put this in a basic for loop, I get this error: Error using ==> lpc at 64 (this is at lpc.m file) ........
I search on it but can not solve the problem, Can anyone help please? Regards.

답변 (1개)

Greg Dionne
Greg Dionne 2016년 11월 17일
편집: Greg Dionne 2016년 11월 17일
In my version, line 64 generates an error when your input signal is empty (i.e. has no data).
Set a trap on it and then click on the "function callstack" in the editor tab to see what portion of the signal you are selecting.
I think you want to do something like:
numSegments = floor(length(W)/50);
for i=1:numSegments
indices = (i-1)*50+(1:50);
a = lpc(W(indices),P);
...
end
If you're comfortable with matrices... you can get them all in one shot:
M = 50;
N = floor(length(W)/50);
Wm = reshape(W(1:M*N),M,N);
a = lpc(Wm,P);
  댓글 수: 2
micpro
micpro 2016년 11월 18일
Thank you! It works, Another question, How can I plot only formants? (as dots)
Greg Dionne
Greg Dionne 2016년 11월 18일
There are a number of competing ways to plot formants (e.g. mel scale). Once you've got the f1 and f2 scaled the way you want, you can try:
% scale
mel1 = 1127*log(1+f1/700);
mel2 = 1127*log(1+f2/700);
% plot
plot(mel1, mel2, '.')
xlabel('f1 (mel scale)');
ylabel('f2 (mel scale)');

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

Community Treasure Hunt

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

Start Hunting!

Translated by