How to include a variable in "xlswrite" matrix name and cell range?
3 ビュー (過去 30 日間)
古いコメントを表示
Dear members,
I want to include variables x,x1 and x2 in the following function, where x represents the matrix and xls file names and x1 x2 represent the range overwhich the matrix will be written in excel.
xlswrite('Jx.xls',Jx,'Ax1:Bx2')
This function will be written in a "double for loop" that subtitutes x first then x1 x2 thus generating multiple excel files.
Thank you!
0 件のコメント
採用された回答
Walter Roberson
2019 年 10 月 29 日
Put your arrays into a single cell array Jx
filename = sprintf('J%d.xls', x);
range = sprintf('A%d:B%d', x1, x2);
xlswrite(filename, Jx{x}, range);
You might have noticed that I did not dynamically generate variable names J1 J2 and so on to write out. See http://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval
その他の回答 (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!