how to combine matrix column and saving them as a separate text file?
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
Jan
on 20 Jun 2017
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 Comments
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!