フィルターのクリア

How to pass the same function to different columns?

1 回表示 (過去 30 日間)
Armando MAROZZI
Armando MAROZZI 2020 年 4 月 3 日
コメント済み: Armando MAROZZI 2020 年 4 月 3 日
I would like to pass the same function to all the columns of an object.
I tried this code but it doesn't work
for j = 1:3
autocorr(VAR.res(:,j))
end
where basically I wanted to tell MATLAB "compute autocorrelation for all the 3 columns of VAR.res".
What did I do wrong?
Thanks
  2 件のコメント
Rik
Rik 2020 年 4 月 3 日
That is not an internal Matlab function, unless you meant autocorr. Also, do you want to treat each call as totally separate, or do you want to correlate those columns in some way as well?
Armando MAROZZI
Armando MAROZZI 2020 年 4 月 3 日
Yes, sorry, just edited. I want to treat each call as totally separate

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

採用された回答

Rik
Rik 2020 年 4 月 3 日
You need to specify the target axes, otherwise the function will use gca for each call, so that will be the same axes.
figure(1),cfl(1)
n_cols=size(VAR.res,2);
for col = 1:n_cols
ax=subplot(1,n_cols,col);
autocorr(ax,VAR.res(:,col))
end
  1 件のコメント
Armando MAROZZI
Armando MAROZZI 2020 年 4 月 3 日
thank you very much! Got it now! thanks again

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by