MATLAB: Read a .mat file and write .csv without opening matlab

csvwritedlmread

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!

Best Answer

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);