Exercise 1.10: Error messages with array operations

Consider the function: $ f(x) = \frac{x^3}{1+x^2}$

We want to declare the row vector $ [f(0), f(0.2),\dots, f(1.8), f(2)]$ to the variable $ f$ . To perform the exercises below you first have to enter the array $ x$ with arguments $ (0,0.2,\dots,1.8,2.0)$ . Thus; >> x = 0:0.2:2
a)
Perform the exercise: >> f = x.^3/(1+x.^2).
MATLAB gives a result! But why is it not an array with function values?

REMARK:
IF YOU GET A RESULT, ALWAYS CHECK THAT RESULT!
b)
Perform the exercise: >> f = x^3./(1+x.^2).
What does the MATLAB error mean?



Previous      Next      Up      Answer


Esteur 2010-03-22