MATLAB Answers

xlswrite with flexible column range

10 ビュー (過去 30 日間)
adi kul
adi kul 2017 年 2 月 2 日
回答済み: Jan 2017 年 2 月 2 日
Hello All, I have a script which reads the data from excel file interactively such that:
data=xlsread(xlsname, -1);
Where xlsname is the name of excel file. Now after calculations, I have to write the data in excel file. Now the calculations are based on selected data and user can select 3 rows, 30 rows or 300 rows.
Now I have written the data in excel as:
xlswrite('output_data',result,'A1:C1500');
So if the data is not fo 1500 row, the remaining cells shows "NaN" values in output file. So what I want to put is
xlswrite('output_data',result,'A1:n');
where n will be the length of data selected. is this possible? if yes then how?

回答 (1 件)

Jan
Jan 2017 年 2 月 2 日
xlswrite('output_data', result, sprintf('A1:A%d', numel(result)));

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by