Questions about producing text file with data

2 次查看(过去 30 天)
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!

回答(1 个)

madhan ravi
madhan ravi 2018-12-2

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by