How do I print my data to a .txt file?
3 views (last 30 days)
Show older comments
Haven't been able to make sense of the info on MathWorks. All I'm trying to do is write the outputted vector from my function to a text file.
Here's what I've tried
fileID=fopen('solution.txt');
fprintf(fileID,'%e',x);
x is the outputted 1x5 or 1x10 vector. Just want to put it into a text. Any help on what I'm doing wrong?
0 Comments
Accepted Answer
More Answers (1)
Stephen23
on 24 Mar 2015
Edited: Stephen23
on 24 Mar 2015
according to the fopen documentation you need to supply the second option permission to tell it that you want to write to the file:
fid = fopen(filename,'wt');
You should probably use the text option too, as I have shown in my example above.
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!