Questions about producing text file with data

2 views (last 30 days)
g
g on 2 Dec 2018
Answered: madhan ravi on 2 Dec 2018
I have some data that contains two columns, and I want to print that data to a text file. This is my current scheme:
fileID = fopen('data.txt','w');
fprintf(fileID,'%f %f\n',data');
fclose(fileID);
However, I want to be able to add a string "label" to the end of the text file.
I tried the following, but it did not work:
fileID = fopen('data_%s.txt',label,'w');
fprintf(fileID,'%f %f\n',data');
fclose(fileID);
where label is a string variable that is defined earlier. How would I correctly do this so that it outputs data_thelabel.txt as my text file?
Additionally, one of the columns of data is just standard numbers, however, I want to the second column to be in scientific notation. How would I go about doing that for just the second column in the text file?
Thanks!

Answers (1)

madhan ravi
madhan ravi on 2 Dec 2018

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!