Save a matrix into text files with different names
3 ビュー (過去 30 日間)
古いコメントを表示
I have a big matrix. I am wondering how to separate it into different columns and save each column into a text file with a specified name? For example, if A=[1 2 3; 4 5 6; 7 8 9]
the result should be as X_1=[1;4;7], X_2=[2;5;8] and X_3=[3;6;8]
Thanks in advance
0 件のコメント
回答 (1 件)
Nihar Deodhar
2017 年 1 月 9 日
The following illustration might help:
A=[1 2 3; 4 5 6; 7 8 9];
for i = 1:size(A,2)
X_i = A(:,i);
filename = sprintf('X_%d.txt', i);
save(filename,'X_i','-ascii')
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!