Writing excel files with different names
6 ビュー (過去 30 日間)
古いコメントを表示
I am batch processing and at the end of each participant's data I am using writematrix to generate an output.
For example:
writematrix(cutoff,'outdataFFT.xlsx','sheet','1');
As you will be aware this generates an excel file of the data cutoff in excel with the file called ouputdataFFT.xlsx.
As I run the next participant in the batch this instruction overwrites the first. Now I can add a save line but I was wondering if there was a way of altering the name of the excel file sequentially. Sort for like
for n = 1:10
writematrix(cutoff,'outdataFFT(n).xlsx')
end
Now I know this doesn't work but was interested in whether there is a way?
回答 (1 件)
David K.
2021 年 1 月 13 日
This can be done nearly the way you guessed:
for n = 1:10
writematrix(cutoff,['outdataFFT',num2str(n),'.xlsx'])
end
The key you missed is the need to convert n to a string. After that, matlab is able to nicely concatenate these strings together.
Another function that some may prefer is using sprintf:
for n = 1:10
writematrix(cutoff,sprintf('outdataFFT%d.xlsx',n))
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!