필터 지우기
필터 지우기

I am trying to sort the output data, I need a help to write data into excel file using for loop.

조회 수: 1 (최근 30일)
I am trying this, but the excel file is getting rewritten for every iteration and values in the cell are getting replaced. I don't know how to replace the "A2" and "B2" with 'AN' and 'BN' so that for the first iteration the values are written into file's A1, B1 cells respectively... "
u_real = real(u);
v_real = real(v);
for n = 1:100000
if and(u_real>0, v_real>0)
xlswrite('new.xlsx',u_real(n),'sheet1','A2');
xlswrite('new.xlsx',v_real(n),'sheet1','B2');
end

채택된 답변

dpb
dpb 2015년 8월 8일
편집: dpb 2015년 8월 8일
See the manner in which the sequential file names are generated in How_can_I_process_a_sequence_of_files? Same idea for the cell indices as function of the loop index variable. NB: you can also increment the characters if changing columns by addition in Matlab. That is,
>> char('A'+10)
ans =
K
>>
Of course, if you were to go past 'Z' you'll have to build the two-character indices; Matlab isn't that clever or tied to Excel... :)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by