creating a for loop with a mixture of strings and numbers as outputs
1 回表示 (過去 30 日間)
古いコメントを表示
I want to create a for loop that will have the following output:
"trial1.csv" on its first run, "trial2.csv" on its second run, "trial3.csv" on its third run......etc. What is the most efficient way of doing that?
trial1 = sprintf ('max%d', k) which gives me the trialk piece but I was not able to add the .csv piece. It gave me an error every time I tried adding it in different ways. I found a work around but needed 3 lines of code instead of 1. It works but doesn't seem to efficient.
I am still learning matlab so I am sure its a simple problem
Thanks in advance!
0 件のコメント
採用された回答
James Tursa
2016 年 3 月 16 日
編集済み: James Tursa
2016 年 3 月 16 日
Does this do what you want:
sprintf('max%d.csv', k)
In general, you can use concatenation brackets [ ] to join strings together. E.g., this would produce the same result:
[sprintf('max%d', k) '.csv']
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!