フィルターのクリア

How to create for loop to find coefficients of segments?

1 回表示 (過去 30 日間)
jack star
jack star 2016 年 4 月 12 日
コメント済み: jack star 2016 年 4 月 13 日
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?
  1 件のコメント
Star Strider
Star Strider 2016 年 4 月 12 日
Linear prediction filter coefficients: lpc

サインインしてコメントする。

採用された回答

Image Analyst
Image Analyst 2016 年 4 月 12 日
Try this:
[rows, columns] = size(y);
p=10;
for col = 1 : columns
thisColumn = y(:, col);
[a(col), g(col)] = lpc(thisColumn, p);
end
  5 件のコメント
Image Analyst
Image Analyst 2016 年 4 月 12 日
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 2016 年 4 月 13 日
Thank you very much for your help.

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by