How to Save Matrices to excel multiple times with incremental excel name to avoid overwrite
조회 수: 1 (최근 30일)
이전 댓글 표시
let C be a Matrix containing the data from matrix A and B
PROGRAM:
.
.
.
for i=1:3,
C = [A(:,i),B(:,i)];
xlswrite(C,header,colnames,'C.xls');
end
.
.
.
How would i fix xls write such that... it will have 3 Excel file saved...
i.e. C1.xls, C2.xls, C3.xls as i get the data in my "for loop"
because the syntax right now is overwriting C.xls everytime. and I end up with one excel file
댓글 수: 0
채택된 답변
Sarah Wait Zaranek
2012년 5월 11일
The easier way to to construct a new filename within the loop by converting the index to a string and adding it the original name using string concatenation.
Example below ---
for ii = 1:3
filename = ['C' num2str(ii) '.xls'];
% then use filename in xlswrite call
end
추가 답변 (1개)
Thomas
2012년 5월 11일
Cant test this right now, but you could try..
for ii=1:3,
C = rand(1,10); % some random data
fname=strcat('C',num2str(ii),'.','xls');
xlswrite(fname,C);
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!