Why getting this error ? how to fix it ?

3 ビュー (過去 30 日間)
Bob
Bob 2019 年 3 月 15 日
コメント済み: Jan 2019 年 3 月 19 日
Hi all,
I am trying to achive coeffcient correlation but getting erorr "Unable to perform assignment because the indices on the left side are not compatible with the
size of the right side".
Following function being used:
for i=1: length(a_sw)-300
x(i)= corrcoef(a_sw (i:i+300), b_sw(i:i+300));
Time_x=i;
end
figure(1)
plot(a_sw,b_sw,'ko',a_sw,b_lin,'r');
xlabel('A')
ylabel('B')
Any help would be appreciated.
Thanks
  5 件のコメント
Alex Mcaulley
Alex Mcaulley 2019 年 3 月 15 日
Yes, unless a_sw and b_sw were scalars
Jan
Jan 2019 年 3 月 19 日
@Bob: If you really appreciate the help of the forum, do not delete your question after solutions have been posted.

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

採用された回答

Alex Mcaulley
Alex Mcaulley 2019 年 3 月 15 日
編集済み: Alex Mcaulley 2019 年 3 月 15 日
As Adam said, probably your a_sw and b_sw are arrays and then the output of this
corrcoef(a_sw (i:i+300), b_sw(i:i+300));
is a matrix.
Then, to store those matrix you can use, for example, a cell array:
for i=1: length(a_sw)-300
x{i}= corrcoef(a_sw (i:i+300), b_sw(i:i+300));
Time_x=i;
end
figure(1)
plot(a_sw,b_sw,'ko',a_sw,b_lin,'r');
xlabel('A')
ylabel('B')

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTime Series Collections についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by