MATLAB Answers

How to store vector in a loop and print into excel file all at once?

8 views (last 30 days)
Tanu Shree
Tanu Shree on 29 Jun 2020
Edited: KSSV on 29 Jun 2020
I want to write all the R at once into a excel file. I have been trying different method below loop just write the last results. Any Idea what mistake I am doing?
L = length(y_train_corr(1,:));
R = corrcoef(y_train_corr(:,2),y_train_corr(:,3));
Es = cell(L-2,1);
for i = 1:L-2
R= corrcoef(y_train_corr(:,2),y_train_corr(:,2+i));
Es{i} = R;
end;
xlswrite('train_corr_coeff.xlsx',R);

  0 Comments

Sign in to comment.

Accepted Answer

KSSV
KSSV on 29 Jun 2020
Edited: KSSV on 29 Jun 2020
You are wrtitng R in the xlswrite command. Replace R with Es.
L = length(y_train_corr(1,:));
R = corrcoef(y_train_corr(:,2),y_train_corr(:,3));
Es = cell(L-2,1);
for i = 1:L-2
R= corrcoef(y_train_corr(:,2),y_train_corr(:,2+i));
Es{i} = R;
end;
xlswrite('train_corr_coeff.xlsx',Es);

  0 Comments

Sign in to comment.

More Answers (0)