How to output both rho and pvalues of the Corr function when having an iterative loop
이전 댓글 표시
Hi, I can't seem to get around how to do this. I have 12xm matrix (a1) of which I want to calculate the linear rank correlation rho an pvalues (using Corr function and pearson correlation type) from paired columns vectors, i.e. between 6 rows in each column and the next 6 rows in that column (these are replicate measurements, designated rep1 and rep2, respectively), and I want to iterate that with a for loop for all the m columns in the matrix a1.
I have it working so that it spits out the rho values in a 1xm vector, but I don't know how to get the script to do that also for the p-values associated with each correlation.
this is the script I have:
results=zeros(1,size(a1,2));
rep1=a1(1:6,1:size(a1,2));
rep2=a1(7:12,1:size(a1,2));
for repit = 1:size(a1,2);
results(repit) = corr(rep1(:,repit),rep2(:,repit));
end
I know that [r,p] = corr(x,y) gives me both the r and p-value, but how do I build this into the iterative loop that I have going so that it does that for each each two column vectors in every columns of the a1 matrix.....?
I hope I am making this clear enough... otherwise, don't bother asking for clarifications.
Thank you.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Interpolation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!