Sunday, February 10, 2013

Run matlab program from shell

This is nice!
#!/bin/bash filename=program.m; cat > $filename << EOF % It is matlab script disp('Hello World') A=zeros(3,3); if size(A)==3 disp('Hello again') end EOF chmod +x $filename matlab -nodesktop -nosplash -nodisplay -r "run ./$filename ; quit;"
-->

Tuesday, February 5, 2013

Recursive Action in Folders using matlab

I wanted to cleanup some of the old pdf files but not clean out the .doc/.tex in there. Also, .zip was of no use, so wanted to get rid of that too! This small matlab script did the job! jj=3 because . and .. are first two from the dir.
filename =dir; filename.name for jj = 3:length(filename) this = filename(jj).name; if isdir(this) this eval(['cd ' this]) !rm -r *.pdf !rm -r *.zip cd .. end end
-->