how to combine matrix column and saving them as a separate text file?
1 次查看(过去 30 天)
显示 更早的评论
suppose i have two large matrices of the same size (10950*45) and i would like to combine each corresponding column of the two matrices into a separate text file with naming as file1, file2.....file45. below is just an example what i wanted to achieve.
A=randi(1000,100);
B=randi(1000,100)*5;
file1=[col1_A Col1_B]; file2=[col2_A Col2_B];file3=[col3_A Col3_B].....file100=[col100_A Col100_B]
Thanks in advance
0 个评论
回答(1 个)
Jan
2017-6-20
A = randi(1000,100);
B = randi(1000,100)*5;
for k = 1:100
Data = [A(:, k), B(:, k)];
FileName = sprintf('file%d.txt');
... do what you want with the data and the file name
end
You did not specify how the "file1" etc should be created. Avoid to create large text files, because binary files are much more efficient. Text files are useful only, if human should read and edit them - or if another programmer forgot this important detail.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Other Formats 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!