To evaluate y = (2x^2)/((x-2)(x-6))
in MATLAB, we first need to define a function that represents the polynomial.
main.m76 chars4 lines
This code defines a function named mypolynomial
that takes a scalar or array input x
and returns the corresponding value(s) of y
.
To evaluate the polynomial at specific values of x
, we can simply call the function with the input value(s):
main.m46 chars4 lines
This code will evaluate the polynomial at 101 evenly-spaced values of x
between 0 and 10, and plot the corresponding values of y
.
gistlibby LogSnag