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

조회 수: 2 (최근 30일)
Tanu Shree
Tanu Shree 2020년 6월 29일
편집: KSSV 2020년 6월 29일
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);

채택된 답변

KSSV
KSSV 2020년 6월 29일
편집: KSSV 2020년 6월 29일
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개)

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by