How do I format a .txt file I've created?

1 view (last 30 days)
Im trying to display max_speed for 6 different satellites in a .txt file, however when i run this code only sat_id appears, not max_speed. Can someone help me fix this?
fileID=fopen('report.txt','w');
fprintf(fileID,'name\n');
fprintf(fileID,'studentnumber\n');
fprintf(fileID,'sat_id,max_speed(m/s),min_speed(m/s),orbital_period_before(s),orbital_period_after(s)\n');
for n = 1:6
fprintf(fileID,'%d\n', stat(n).sat_id);fprintf(fileID,'%15:9e %15:9e\n', stat(n).max_speed);
end fclose(fileID);
end

Accepted Answer

Stephen23
Stephen23 on 18 Mar 2018
Edited: Stephen23 on 18 Mar 2018
%15:9e
is not a valid format string. Perhaps you meant to write a decimal point:
%15.9e

More Answers (0)

Community Treasure Hunt

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

Start Hunting!