フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Help with code

1 回表示 (過去 30 日間)
Mate 2u
Mate 2u 2012 年 5 月 11 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hi everybody, I am having some trouble with some code. My program goes through every substring within a string, finds out where it occurs, and stores the "post" pattern substring. Then it needs to take correlations of all the "post patterns" substrings so it needs to do correlation of all combinations and then take a average.
I would really appreciate if someone can help me. Here is my code (without the correlation part which I could do with some help....also theres a error when Im trying to store the post pattern substrings).
A = [1 2 2 2 1 2 3 4 1 2 2 2 2 1 2 3 4 1 1 1 1]
n=3; %n
x=3;
for i =1:length(A)-n+1
ZZ= strfind(A,A(i:i+n-1));
if (length(ZZ)==1)
C(i)=0;
end
if (length(ZZ)>1)
clear array;
index =1;
for j=1:length(ZZ)
array(:,index) = A(ZZ(j)+n:ZZ(j)+n+x);
index=index+1;
end
R=corrcoef(array);
RPairs = [nchoosek(1:size(array,2),2), nonzeros(tril(R,-1))];
M(i) = mean(RPairs(:,3))
end
end
I thank everyone for their contribution
ERROR: Attempted to access RPairs(:,3); index out of bounds because size(RPairs)=[1,2].
I am trying to get the average of the bottom traingular section of correlation matrix.
  5 件のコメント
Dr. Seis
Dr. Seis 2012 年 5 月 11 日
You have a lot more code implementation problems than just this... not only have you hard-coded the number of columns to be 3 (your current error), you haven't taken into account that the indexes associated with "ZZ(j)+n:ZZ(j)+n+x" will at some point in your loop give you values greater than the "length(A)".
Mate 2u
Mate 2u 2012 年 5 月 11 日
Could you help me then please.

回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by