How to use dlmwrite in a for loop?
3 ビュー (過去 30 日間)
古いコメントを表示
Hi everybody, I want to use dlmwrite to save data in .dat format for a cell array in the workspace.
Thats what I want obtain:
dlmwrite('Ejex1.dat', Ejex{1,1}','delimiter','\t','precision',16)
dlmwrite('Ejex2.dat', Ejex{1,2}','delimiter','\t','precision',16)
dlmwrite('Ejey1.dat', Ejey{1,1},'delimiter','\t','precision',16)
dlmwrite('Ejey2.dat', Ejey{1,2}','delimiter','\t','precision',16)
But the problem is when I try to put in a for loop, I tried many ways to obtain that but it doesn't work well:
for i=1:numfiles
NameFile(i)=filename(i)
dlmwrite('NameFile%d.dat',Ejex{1,i},'delimiter','\t','precision',16)
end
Another:
for i=1:numfiles
NameFile(i)=filename(i)
dlmwrite(NameFile.dat, Ejex{1,i},'delimiter','\t','precision',16)
end
Thanks in advance!! I hope you can help me
0 件のコメント
採用された回答
Joseph Cheng
2015 年 9 月 18 日
matlab is not going to fill in the %d number for you. you should be using something like sprintf to a variable to generate the filename for dlmwrite.
for i = 1:size(Ejex,1)
Xfilename = sprintf('Ejex%d.dat',i);
disp(Xfilename)%use xfilename for your dlmwrite
end
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Import and Export についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!