23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Calling Functions<br />

The example above meets all three criteria and is therefore a function call<br />

using command syntax:<br />

ls ./d<br />

The following examples are not function calls using command syntax:<br />

% No white space following the ls identifier<br />

% Interpretation: elementwise division<br />

ls./d<br />

% Parenthesis following white space<br />

% Interpretation: function call using function syntax<br />

ls ('./d')<br />

% Assignment operator following white space<br />

% Interpretation: assignment to a variable<br />

ls =d<br />

% Operator following white space, followed in turn by<br />

% more white space and a variable<br />

% Interpretation: elementwise division<br />

ls ./ d<br />

Passing Certain Argument Types<br />

This section explains how to pass the following types of data in a function call:<br />

• “Passing Strings” on page 4-61<br />

• “Passing Filenames” on page 4-62<br />

• “Passing Function Handles” on page 4-63<br />

Passing Strings<br />

When using the function syntax to pass a string literal to a function, you<br />

must enclose the string in single quotes, ('string'). For example, to create a<br />

new directory called myapptests, use<br />

mkdir('myapptests')<br />

4-61

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!