How to write a matrix to a text file
10 views (last 30 days)
Show older comments
Attached I have the original file "hightemp.txt"
I need to create a script that Converts the text file to a matrix, adds 1900 to the first column, and then writes the matrix to a new text file called "Year2000.txt"
here is what I have tried but it says theres an error
A = dlmread('hightemp.txt');
A(:,1)= A(:,1) + 1900;
dlmwrite('Year2000.txt',A,'delimiter','\t','newline','pc')
also
A = dlmread('hightemp.txt');
A(:,1)= A(:,1) + 1900;
dlmwrite('Year2000.txt',A)
both give me an error on the dlmwrite part (we do not necessarily have to use dlmwrite)
0 Comments
See Also
Categories
Find more on Text Files 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!