lpc function for smaller intervals

2 views (last 30 days)
micpro
micpro on 17 Nov 2016
Commented: Greg Dionne on 18 Nov 2016
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.

Answers (1)

Greg Dionne
Greg Dionne on 17 Nov 2016
Edited: Greg Dionne on 17 Nov 2016
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 Comments
micpro
micpro on 18 Nov 2016
Thank you! It works, Another question, How can I plot only formants? (as dots)
Greg Dionne
Greg Dionne on 18 Nov 2016
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)');

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!