# How can i fill a pre-allocated matrix 2D?

조회 수: 1(최근 30일)
Harry Smith 2021년 7월 25일
댓글: Image Analyst 2021년 7월 25일
Hello everyone!
i hope you can help me.
My code is:
[A, B]=size(storage);
nan_matrix=NaN(500,1000);
for ii=1:A
for k=1:B
[x,y]=corr(....)
end
end
%put x-values in the nan_matrix and save this matrix
How?
##### 댓글 수: 6표시숨기기 이전 댓글 수: 5
dpb 2021년 7월 25일
[rho, p_val]=corr(x,y, 'type', 'spearman');
the x_dimension is: 300x4
So, what is y?
"If you input matrices X and Y, rho is a k1-by-k2 matrix, where k1 and k2 are the number of columns in X and Y, respectively. The entry rho(a,b) is the pairwise linear correlation coefficient between column a in X and column b in Y."
I still don't follow why you think you need other storage...

댓글을 달려면 로그인하십시오.

### 답변(1개)

Image Analyst 2021년 7월 25일
I'd use xcorr2().
##### 댓글 수: 2표시숨기기 이전 댓글 수: 1
Image Analyst 2021년 7월 25일
It's a sliding window that gives you the correlation of one set of data with another. What were you thinking of doing when you had corr() inside the double nested for loop?

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

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

Start Hunting!

Translated by