I have an polynomial f(x) = 4x^5 + 5x^4 + 2x^3 +2x^2 +3x. And x ranges from {0 to 63}. How do I code this so I can display answer corresponding to every value of x.?

 Accepted Answer

p=[4 5 2 2 3 0];
x0=1;
polyval(p,x0);
evaluates your polynomial at x0=1.
Best wishes
Torsten.

6 Comments

Note that in Torsten example x0 could be a vector or matrix
polyval(p, [1 2 3]) %evaluate polynomial at x = 1, x = 2 and x = 3
Sir/Mam, but I need to evaluate that polynomial from x = 0 to 63. Then should I define that x vector as [0 1 2 3 4 5 6... 63]?
Set
p=[4 5 2 2 3 0];
x0=linspace(0,63,64);
f0=polyval(p,x0);
Best wishes
Torsten.

Sign in to comment.

More Answers (1)

(a) Write down MATLAB command for each of the following polynomials.
(i) 2x
2
- 5x
4+ 8x (ii) 2x
5 + sin 40

Categories

Tags

Asked:

on 22 Mar 2016

Answered:

on 20 Aug 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!