Want to convert .MAT to .TXT
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello, I have multiple .MAT structures with multiple variable names and long vectors (3000+ of data) that I would like to process such that the data is put into a .TXT file with the variable names as the column header. EX: (i.e. X=[1.90,2.3] , Y=[2.5467,10.87], Z=[3.134,100.98]. So X, Y, Z are the column headers and the data fall underneath each respective column with the DECIMAL places properly aligned on top of each other.
Question:
I there a script that can do what I need?
Please help
Thank you
Sara
0 Commenti
Risposte (2)
Adam
il 20 Gen 2017
doc fprintf
should be able to do what you want, but you'll have to put together the format specification yourself and work out how to get decimal places lined up. This isn't usually something that is important in a text file for raw data.
0 Commenti
Jorge Mario Guerra González
il 20 Gen 2017
Modificato: Jorge Mario Guerra González
il 20 Gen 2017
Here is quick way to do that. Using fprint as @Adam says. (This writes with 5 decimal places)
X=[1.90; 2.3]; Y=[2.5467;10.87]; Z=[3.134;100.98];
fid = fopen('example.txt','wt');
fprintf(fid, '%s\t %s\t %s\n', 'X','Y','Z');
fprintf(fid,'%0.5f\t %0.5f\t %0.5f\n',[X Y Z]);
fclose(fid);
You can import it with the headers to excel or whatever.
0 Commenti
Vedere anche
Categorie
Scopri di più su Structures in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!