Read a .mat file and write .csv without opening matlab
65 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Michael02139
il 14 Ott 2016
Commentato: Michael02139
il 25 Ott 2016
I would like to read a ".mat" file and write it out as ".csv" file without opening matlab.
Basically this:
M = dlmread('FileName.mat', '\t', 1, 0);
csvwrite('FileName.csv', M)
but then without opening matlab.
I'm using linux command line.
Thanks!
0 Commenti
Risposta accettata
Marc Jakobi
il 14 Ott 2016
You won't be able to run a Matlab-file without opening Matlab - unless you use another program that is compatible.
However, you could write a bash script that runs Matlab in a "hidden" mode:
#!/bin/bash
matlab -nodisplay -nodesktop -r "run /path_to_script/my_script.m"
P. S. I wouldn't recommend csvwrite. fprintf is a lot more flexible and faster.
fid = fopen('filename.csv','w');
fprintf(fid, formatSpec, data);
fclose(fid);
3 Commenti
Walter Roberson
il 14 Ott 2016
You would want
fprintf(fid, formatSpec, [t, P].');
to write t and P into columns.
Più risposte (2)
Walter Roberson
il 25 Ott 2016
Is the mat file text with tab delimiters or is it a binary file created by save()?
If it is text with tab delimiters then consider just using sed to change the tabs into comma
Vedere anche
Categorie
Scopri di più su Low-Level File I/O 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!