plotting a polynomial problem
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
hello everyone!
maybe it's too simple, but i got a little angry trying to plot a polynomial
let's say : u=a*x+b*x^2+c*x^3+d*x^4 and x=0:0.01:1 when i try to evaluate u the red message says
Error using ==> mpower Matrix must be square.
i had no problem plotting another function like f=a-b*exp(4*x)+c*x
why does the error come up?
(i found something for "polyval" function but how do i use it when i have only x multipliers?)
I can evaluate the polynomial when x has a single value and it is not an array
0 comentarios
Respuestas (1)
Azzi Abdelmalek
el 28 de Nov. de 2012
Editada: Azzi Abdelmalek
el 28 de Nov. de 2012
use operations element by element .^
x=0:0.01:1
u=a*x+b*x.^2+c*x.^3+d*x.^4
because x is a vector, to compute x^2, x must be square. So you can use
[2 4 6].^2=[2^2 4^2 6^2]
0 comentarios
Ver también
Categorías
Más información sobre Polynomials en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!