plotting a polynomial problem
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Azzi Abdelmalek
2012년 11월 28일
편집: Azzi Abdelmalek
2012년 11월 28일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Polynomials에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!