Want to convert .MAT to .TXT
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (2)
Adam
le 20 Jan 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 commentaires
Jorge Mario Guerra González
le 20 Jan 2017
Modifié(e) : Jorge Mario Guerra González
le 20 Jan 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 commentaires
Voir également
Catégories
En savoir plus sur Structures dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!