6 views (last 30 days)

Hi,

I have problem as my code running for infinite time while I am plotting my arrays to achive coeffcient correlation.

here is my code:

for i=1:length(A)-300

Rx{i}= corrcoef(A (i:i+300), S(i:i+300));

Time_Rx=i;

B{1,i} = Rx(i)

C{1,i} = Time_Rx

end

(Aiming for plot Rx as a function over time)

plotting by using:

plot(B,C);

Can not figure out what is wrong, Any help would be appriciable.

BERGHOUT Tarek
on 6 Apr 2019

Edited: Walter Roberson
on 6 Apr 2019

if you want to plot Rx , then you should plot B not C, and you can't plot B vs C in this example because C and B they dont have the same length ( dimensions are not the same), try this code , I hope that it is helpful:

clear all;

clc;

%%%

t=1:600;

A=0.25;

B=1.25;

f1=0.5;

f2=0.025;

S=A*sin(f1*t)+B*cos(f2*t)+wgn(size(t,1),size(t,2),3);

A=S+randn(size(S));

%%%

B=[];

for i=1:length(A)-300

Rx=corrcoef(A (i:i+300), S(i:i+300));

B=[B Rx];

end

plot(1:size(B,2),B);

Opportunities for recent engineering grads.

Apply Today
## 20 Comments

## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_684981

⋮## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_684981

## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_684984

⋮## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_684984

## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_685064

⋮## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_685064

## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_690437

⋮## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_690437

## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_690481

⋮## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_690481

## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_690548

⋮## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_690548

## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_690567

⋮## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_690567

## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_690574

⋮## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_690574

## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_690577

⋮## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_690577

## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_690582

⋮## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_690582

## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_691413

⋮## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_691413

## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_691417

⋮## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_691417

## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_691423

⋮## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_691423

## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_691428

⋮## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_691428

## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_691439

⋮## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_691439

## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_691451

⋮## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_691451

## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_691456

⋮## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_691456

## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_691457

⋮## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_691457

## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_692707

⋮## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_692707

## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_693202

⋮## Direct link to this comment

https://fr.mathworks.com/matlabcentral/answers/452001-code-running-for-infinite-while-plotting-my-array-for-correlation#comment_693202

Sign in to comment.