Wednesday, 22 August 2012

Reduce file size/quality of pdf using ghostscript

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
view raw reduce.sh hosted with ❤ by GitHub

Write and execute a Matlab script without opening Matlab

Here's an example of using cat to write your m-file and then execute from the command line. This particular example will just plot and print 10 random numbers.
filename=my_script.m;
cat > $filename << EOF
figure
plot(rand(1,10))
print -dtiff test.tif
close
EOF
chmod +x $filename
/usr/local/MATLAB/R2011b/bin/matlab -nodesktop -nosplash -r "my_script;quit;"
view raw writem.sh hosted with ❤ by GitHub