MATLAB Answers

How can I solve the problem : Unrecognized function or variable 'polyeval'.

113 views (last 30 days)
jiangyifei zhu
jiangyifei zhu on 25 Jan 2020
Commented: Walter Roberson on 26 Jan 2020
I am using the MATLAB Online on windows in
Is that because I need to download the library(APP) for "polyevalpolyeval" by myself or I wrote any wrong codes?
% Evaluate Taylor polynomials for exp(x) about x = 0 on [-b, b].
% Initialized
b = input('Give the number b defining the interval [-b, b]');
h = b/10;
x = -b:h:b;
max_deg = 4;
% the coefficients are stored in c;
c = ones(max_deg+1, 1);
fact = 1;
for i = 1:max_deg
fact = i*fact;
c(i+1) = 1/fact;
This part goes wrong which said that Unrecognized function or variable 'polyeval'.
Error in exp_taylor (line 17)
p1 = polyeval(x,0,c,1);
% calculate the Taylor polynomials
p1 = polyeval(x,0,c,1);
p2 = polyeval(x,0,c,2);
p3 = polyeval(x,0,c,3);
p4 = polyeval(x,0,c,4);
% calculate the errors in the taylor polynomials
true = exp(x);
err1 = true-p1;
err2 = true-p2;
err3 = true-p3;
err4 = true-p4;
% print the errors in tabular format
diary exp_taylor
disp(' x exp(x) err1 err2 err3 err4')
for i =1:length(x)
diary off


jiangyifei zhu
jiangyifei zhu on 26 Jan 2020
Thanks! I have one more question that as I download the file, how can I execute my code by using that file online?

Sign in to comment.

Answers (0)

Sign in to answer this question.

Translated by