saving matlab results
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
hi there, anyone know hot to save results to a file in matlab? suppose i had this x,y,z data that i want to save it as results.str that is openable via matlab. anyone can help? thank you very much
0 Commenti
Risposta accettata
Jan
il 4 Mag 2011
"Put z inthe first column" is not an exact definition of the output. Do you want to write an ASCII file?
FID = fopen(FileName, 'w');
if FID < 0, error(Cannot open file); end
data = [z, y, x];
fprintf(FID, '%g %g %g\n', transpose(data));
fclose(FID);
See "help fprintf", if you want to specify another numerical format, e.g. more digits after the dot.
2 Commenti
Jan
il 4 Mag 2011
@Win: Simply read "help fopen" to see, what this command does: " 'w' open file for writing; discard existing contents".
FWRITE writes binary data, FPRINTF writes ASCII data. Both could solve your problem, it only depends on your needs. If the file need not be readable by human, a binary format is more efficient. How is the ".str" format defined?!
Più risposte (1)
Andreas Goser
il 4 Mag 2011
From your description, I'd say you have x, y, z in your MATLAB workspace. Then you can save the data with the SAVE command. The default is a so called MAT file, but you can also choose the ASCII format. See the documentation for that.
Vedere anche
Categorie
Scopri di più su String Parsing in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!