How can I write both number and text to a file?
Show older comments
I want to write something like this:
BEGIN 0.00 0,0 0.5,1 1,1.5 1.5,1.75 14,2
from matlab to a text file. There are supposed to be a new number on one line, going down. I also have to go this several times for different values. How can I do this effectively?
Accepted Answer
More Answers (1)
Massimo Zanetti
on 19 Oct 2016
Edited: Massimo Zanetti
on 19 Oct 2016
Look here:
Here it is:
x = 'BEGIN 0.00 0,0 0.5,1 1,1.5 1.5,1.75 14,2';
fid = fopen('SomeTextFile.txt','a');
fprintf(fid,'%s\n',x);
fclose(fid);
But, for more complex inputs I suggest to read the help page. Will be useful.
Categories
Find more on Characters and Strings 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!