Saving a text file with strings stored in cell array

3 ビュー (過去 30 日間)
Sandeep Nair
Sandeep Nair 2019 年 1 月 24 日
コメント済み: Stephen23 2019 年 1 月 24 日
I have to create a script 35 times and save it in txt format and the name for the script i have i have stored in cell array.Now i want to
save the file with those 35 strings stored in cell array how to do it?
Eg
a = {'Max_force','Min_force','Avg_force'};
Now i will be running a loop for 3 times and i want my script to be names as Max_force.txt,Min_force.txt and Avg_force.txt

採用された回答

madhan ravi
madhan ravi 2019 年 1 月 24 日
編集済み: madhan ravi 2019 年 1 月 24 日
for k=1:numel(a)
dlmwrite(sprintf('%s.txt',a{k}),data) % can be any exporting command save , writetable etc etc.
% ^^^^^^^^^^^^^^^^^^^^^^----- important part is using sprintf and indexing cell array
end
  1 件のコメント
Stephen23
Stephen23 2019 年 1 月 24 日
Sandeep Nair's "Answer" moved here:
thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by