How to create for loop to find coefficients of segments?

1 visualización (últimos 30 días)
jack star
jack star el 12 de Abr. de 2016
Comentada: jack star el 13 de Abr. de 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?

Respuesta aceptada

Image Analyst
Image Analyst el 12 de Abr. de 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 comentarios
Image Analyst
Image Analyst el 12 de Abr. de 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 el 13 de Abr. de 2016
Thank you very much for your help.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by