using matlab to solve plotting function -
i've been asked plot function f(x) = (x^2 - 3x + 7) / (sqrt(2x +5))
for -1< x <5
how go starting this?
thanks all
matlab works arrays (matrices actually). first, need create array x values:
x = -1: 0.01: 5 where 0.01 interval between consecutive values.
then need calculate y values.
y = (x.^2 - 3*x + 7) ./ (sqrt(2*x + 5)); this quite straightforward. thing need notice dots. .*, ./ operators work element-wise (which need, since want calculate square of values). if instead typed x^2, mean matrix multiplication of x itself, produce wrong values in case.
finally, plot it:
plot(x, y, '.b'); x , y obvious. last part refers color , style of line. in case mean blue dots. other styles see matlab line styles.
Comments
Post a Comment