Page 39 - Computational Colour Science Using MATLAB
P. 39
26 A SHORT INTRODUCTION TO MATLAB
function [out] = treble(in)
out = 3*in;
The text for the function treble should be saved in an M-file called treble.m. The
function is then available to the Command Window or to other M-files or
functions and is simply called in any of the following ways:
treble(x)
y = treble(x);
[y] = treble(x);
The last of these formats is useful since it allows for a function to return more
than one variable. Note also that the function treble will operate on a single
number, a row or column matrix or a matrix.
A wide variety of text books (Borse, 1997; Marchand, 1999) exist for the
reader who wishes to become more familiar with MATLAB before proceeding
with the remainder of this book.