fprintf does not save all the data
Ältere Kommentare anzeigen
In my workspace, I have a 1x1 struct named modes. It has three fields called x,y,z. Each field is 1x46000 and each cell is a number in exponential format. I would like to save the x array to a .dat file. So I did the following
id = fopen('modes_x.dat', 'wt+');
for i = 1:size(modes.x,1)
fprintf(fid, '%s\r\n', modes(i,1).x)
end
fclose(fid)
Only 20566 values are saved to file. Beyond 20566, there are about 18000 zeros followed by more non-zero numbers. Somehow, fprintf stops saving data when it hits the zeros.
I tried replacing %s with %e but the output is blank.
Does anyone know what I am missing here? Too bad there is no option in the menu bar for such a simple task.
Thank you,
Vahid
Akzeptierte Antwort
Weitere Antworten (1)
Vahid Askarpour
am 4 Okt. 2021
0 Stimmen
3 Kommentare
Walter Roberson
am 4 Okt. 2021
Why are you using a %s format to try to output double precision numbers?
Vahid Askarpour
am 4 Okt. 2021
Vahid Askarpour
am 4 Okt. 2021
Kategorien
Mehr zu Classification Trees finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!