Filter löschen
Filter löschen

How to create for loop to find coefficients of segments?

2 Ansichten (letzte 30 Tage)
jack star
jack star am 12 Apr. 2016
Kommentiert: jack star am 13 Apr. 2016
Hi all. I have a data matrix named: y (150x240)
I'm using each column (150 datas) of that matrix to find some parameters.
For example, for first frame:
y1=y(1:150)
p=10;
[a,g] = lpc(y1,p)
And same for second column(y2=y(151:300)) I need to find [a,g] for all columns. How can I create for loop for this?

Akzeptierte Antwort

Image Analyst
Image Analyst am 12 Apr. 2016
Try this:
[rows, columns] = size(y);
p=10;
for col = 1 : columns
thisColumn = y(:, col);
[a(col), g(col)] = lpc(thisColumn, p);
end
  5 Kommentare
Image Analyst
Image Analyst am 12 Apr. 2016
OK - it turns out that lpc is a function in the Signal Processing Toolbox. I don't use that function or know what it does. But if you have just [a,g] then you're overwriting a and g on every iteration so of course it will have only the values from the last iteration. That's why you need to index them. If g is a scalar and a is a 11 element array, you can do
[a(col, :), g(col)] = lpc(thisColumn, p);
Before the loop, preallocate a:
a = zeros(columns, 11);
jack star
jack star am 13 Apr. 2016
Thank you very much for your help.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by