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

1 Ansicht (letzte 30 Tage)
I am using the MATLAB Online on windows in https://matlab.mathworks.com
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;
end
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)
fprintf('%7.3f%10.3f%14.3ef%14.3ef%14.3e\n',...
x(i),true(i),err1(i),err2(i),err3(i),err4(i))
end
diary off
  3 Kommentare
jiangyifei zhu
jiangyifei zhu am 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?

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu File Operations finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by