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 allindicators = 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, ), X(rows)); % Fit with the rows which satisfy condition.end
Can you please help?