Matlab/Octave scripts

From GHER

(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
 +
 +
==Download GHER scripts==
 +
To download the scripts, you need an account on modb. On a Linux/Unix computer, the scripts can be downloaded with the <tt>svn</tt> command:
To download the scripts, you need an account on modb. On a Linux/Unix computer, the scripts can be downloaded with the <tt>svn</tt> command:
Line 20: Line 23:
-
=== Exporting figures ===
+
== Exporting figures ==
Each of the following sections presents a different way to export or save a graphic created using matlab.
Each of the following sections presents a different way to export or save a graphic created using matlab.
-
====Save as matlab .fig file====
+
===Save as matlab .fig file===
A matlab figure can be saved as a .fig file (matlab format) using the command '''saveas'''.
A matlab figure can be saved as a .fig file (matlab format) using the command '''saveas'''.
Line 34: Line 37:
  open('sst2010.fig')
  open('sst2010.fig')
-
====Export in usual image formats====
+
===Export in usual image formats===
The figure can also be exported in various image formats. This is done using the command '''print'''.
The figure can also be exported in various image formats. This is done using the command '''print'''.
Line 45: Line 48:
* ''diagram1'' is the name of the newly created file. Note that the extension is automatically appended.
* ''diagram1'' is the name of the newly created file. Note that the extension is automatically appended.
-
====Export in eps====
+
===Export in eps===
When you want to export figures as Encapsuled PostScript (eps), instead of using
When you want to export figures as Encapsuled PostScript (eps), instead of using
Line 58: Line 61:
The results will have a better quality than the one obtained with print.  
The results will have a better quality than the one obtained with print.  
-
====Export in pdf====
+
===Export in pdf===
When you want to export figures as pdf, instead of using
When you want to export figures as pdf, instead of using
Line 68: Line 71:
  ps2pdf diagram1.eps
  ps2pdf diagram1.eps
-
====Export in svg====
+
===Export in svg===
SVG stands for [http://en.wikipedia.org/wiki/Scalable_Vector_Graphics Scalable Vector Graphics]. To export in this format with matlab, download the package [http://www.mathworks.com/matlabcentral/fileexchange/7401 plot2svg]
SVG stands for [http://en.wikipedia.org/wiki/Scalable_Vector_Graphics Scalable Vector Graphics]. To export in this format with matlab, download the package [http://www.mathworks.com/matlabcentral/fileexchange/7401 plot2svg]
http://www.myoutsourcedbrain.com/2009/07/produce-print-quality-figures-from.html
http://www.myoutsourcedbrain.com/2009/07/produce-print-quality-figures-from.html

Revision as of 16:21, 22 March 2012

Contents

Download GHER scripts

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:


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