Matlab/Octave scripts

From GHER

Revision as of 16:19, 22 March 2012 by Gher (Talk | contribs)
Jump to: navigation, search

To download the scripts, you need an account on modb. On a Linux/Unix computer, the scripts can be downloaded with the svn command:

svn checkout svn+ssh://modb.oce.ulg.ac.be/home/svn/repos/Scripts/trunk Scripts

some instructions from a Windows user?

The scripts are organized in subdirectories. Currently, it only contains:

IO
Input-output functions for the GHER fileformat (in big-endian)


You can include the directory Scripts (with all subdirectories) in your search path by adding the following to your startup.m (matlab) or ~/.octaverc (octave) file:

addpath(genpath('/path/to/Scripts'))

More information about SVN:


Contents

Exporting figures

Each of the following sections presents a different way to export or save a graphic created using matlab.

Save as matlab .fig file

A matlab figure can be saved as a .fig file (matlab format) using the command saveas.

savesas(gcf,'sst2010','fig')

After that, the figure can be loaded again using

open('sst2010.fig')

Export in usual image formats

The figure can also be exported in various image formats. This is done using the command print.

print('-dpng','-r300','diagram1')

where

  • -dpng specifies the output format.
  • -r300 specifies the resolution in dpi.
  • diagram1 is the name of the newly created file. Note that the extension is automatically appended.

Export in eps

When you want to export figures as Encapsuled PostScript (eps), instead of using

print('-depsc','-r300','diagram1')

it is recommended to employ the set of functions exportfig.m, previewfig.m, applytofig.m and restorefig.m, available at http://www.mathworks.com/company/newsletters/digest/december00/export.html

exportfig(gcf,'gher.eps','bounds','tight','Color','rgb','Resolution',300); 

The results will have a better quality than the one obtained with print.

Export in pdf

When you want to export figures as pdf, instead of using

print('-dpdf','-r300','diagram1')

it is recommended to export the figure in eps, as explained in the previous paragraph, and then convert it in pdf, using for instance:

ps2pdf diagram1.eps

Export in svg

SVG stands for Scalable Vector Graphics. To export in this format with matlab, download the package plot2svg

http://www.myoutsourcedbrain.com/2009/07/produce-print-quality-figures-from.html

Personal tools