Project BwN DM 1.1, Deliverable 2009

Printing: If you want to print this document select tools -> export to pdf from the top right corner

Matlab coding guidelines

Help block

All Openearth matlab routines should contain a proper help block to be made before you type any code. There are 4 essential requirements for any matlab function. These requirements are the same as adhered to by the Mathworks themselves. Preferable one cannot distinguish Openearth from official matlab functions.

When you start a new function by calling oetnewfun rather than just edit, these 4 requirements appear in a template. The resulting help block (the first commented section following the function identifier) can look something like this:

%FUNCTIONNAME one line comment on the basic functionality of this function (will appear in MATLAB help request)
%
% In this block important background information should be listed.
%
% syntax:
% [output] = functionName(input)
%
% input:
% inputargument = each of the input arguments should be carefully described
%
% output:
% outputargument = each of the output arguments should be carefully described
%
% example:
% An example of the application can be given here. Preferably in a form
% that can be copied in the Matlab commandline to work.
%
% See also: relatedFunction1, relatedFunction2

Open source copyright statements.

OpenEarth is meant to be open source. Please specify this explicitly for every new function you add. When you start a new function by calling oetnewfun rather than just edit, a GNU LGLP copyright statement with personalized whereabouts information is automatically generated. Various open source license definitions are:

Test function *_test.m

Enclose a working test for function before releasing any code. This code should execute the quintessential test case. In the future such functions are foreseen to adhere to specific requirements to allow for automatic testing of the OpenEarth toolbox.

Keyword value pairs.

Proper alignment

Use

x     = 3; %[m]
width = 3; %[m]

instead of

x=3
width=3

Apply namespace principle for function names

Group similar functions using identical initial letters.

Adhere to the following conventions

Functions should be placed in the existing repository structure as much as possible.

However, the existing OpenEarth is NOT considered ultimate and divine, adjust it when necessary. Generic functions should be stored under 'general', application specific functions under 'applications'.