Trouble with a correlation analysis code
이전 댓글 표시
I'm writing a code to run a correlation analysis between two variables under certain conditions. I want to see if there is a correlation between the second column and the first if the second's value is greater than 0. I wrote the following code, but MATLAB continues to print the error, "Index exceeds matrix dimensions".
clear all
indicators = xlsread('largedata1.xlsx');
X = xlsread('largedata1.xlsx', 1, 'A:A');
rows = indicators(:,2)>0; %Logical vector with the rows which satisfy all conditions.
if any(rows) % True if there is at least 1 row which meats the condition.
md1 = fitlm(indicators(rows, [2]), X(rows)); % Fit with the rows which satisfy condition.
end
Can you please help?
Best, A
댓글 수: 2
Image Analyst
2017년 1월 28일
Can you attach 'largedata.xlsx' so people can try your code?
Alexandra Brian
2017년 1월 29일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Correlation and Convolution에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!