MATLAB Answers

modify code for polynomial function

17 views (last 30 days)
Mohaiminul Islam
Mohaiminul Islam on 7 Sep 2020
Commented: Rena Berman on 9 Oct 2020 at 16:43
i try to modify this code but can't pass .please help with proper code
function fh = poly_fun(p)
function polynomial = poly(x)
polynomial = 0;
ii = 1:length(p)
polynomial = polynomial + p(ii).*x.^(ii-1);
fh = @poly;


Rik on 8 Sep 2020
Unforturnately for Mohaiminul Islam Google cache takes some time to update, so the evidence of his attempt to cheat is foiled. A permalink to what he posted can be found here (will take a few hours to become available).
Removing your question after receiving an answer and help is extremely rude. It is also pointless, because of comments like this enable your teacher to find your post, and because site admins can often restore your edit.
Rena Berman
Rena Berman on 9 Oct 2020 at 16:43
(Answers Dev) Restored edit

Sign in to comment.

Answers (1)

KSSV on 7 Sep 2020
Edited: KSSV on 8 Sep 2020
n = length(p)-1 ; % degree of polynomial
val = sum(p.*(x.^(n:-1:0)))


Show 8 older comments
Mohaiminul Islam
Mohaiminul Islam on 8 Sep 2020
Thanks for helping. can't understand anything . just gonna skip this assignment . :)
KSSV on 8 Sep 2020
There should be sum. I missed it and Walter Roberson pointed it. Hat's off to Walter Roberson for your patience.
Mohaiminul Islam
Mohaiminul Islam on 8 Sep 2020
@walter roberson
Thanks for helping and show me the path
did some silly mistake . just passed the assignment

Sign in to comment.




Community Treasure Hunt

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

Start Hunting!