Graphics Programs Reference
In-Depth Information
Inline objects, like every other matlab construction, is vectorised:
>> f(0:4)
ans =
They can be used in place of other variables:
x = linspace(-4,4);
hold on
Exercise 10 Create a function called funplot that takes the
name of a function and a range of x-values and produces a plot
over that range. For example, the following input should produce
this plot:
The function should work whether you type funplot('sin',[0
pi]) or funplot('sin(x)',[0 pi]) . Hint: What are the ascii
values of ( and ) ? (Answer on page 188.)
27 Cell Arrays
Cell arrays are arrays of different things. The “things” can be scalars,
vectors, matrices, strings (of different length), structures (see section on
structures), or other cell arrays. For example, when we looked at string
matrices we saw that we had to pad the rows with blanks to make them
all the same length. Using a cell array, we can create a “ragged-right
t = {'O sacred receptacle of my joys,';
'Sweet cell of virtue and nobility,';
'How many sons of mine hast thou in store,';
'That thou wilt never render to me more!'}
The curly brackets { and } denote cells. The cell we created above is a
1 cell array:
Search WWH ::

Custom Search