Function evaluates a polynomial
이전 댓글 표시
Hello All,
I have an assignment that I'm having difficulty with. If someone would help me out that would be awesome.
Write a function that evaluates a polynomial. This function takes two arguments, coeff and s. coeff is a vector of any size and represents the coefficients of a polynomial in descending order. s is a scalar and represents the variable in the polynomial.
For example, POLY([ 2 4 0 -9], 3) outputs the value 2 * 3^3 + 4 * 3^2 – 9 POLY([ 2 0 4 0 -9], 3) outputs the value 2*3^4 + 4* 3^2 – 9
Write a main program that asks the user to enter a vector for the coefficients and plot the polynomial.
This is what I have so far: I have figured out the pseduocode for the for loop.
for i:[length(coeff)-1]
sum = vec[i] * X.^(L-1)
total = sum + total;
But I am having difficulty writing the code as I don't understand plots in Matlab. Any help or advise would be greatly appreciated.
Thanks, Ryan
댓글 수: 2
Ryan Wu
2015년 4월 30일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Polynomials에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!