Error using Taylor with order n as variable

4 vues (au cours des 30 derniers jours)
Qingyang Zhang
Qingyang Zhang le 11 Oct 2019
I want to find several taylor polynomials with n = 1:10
I have the following code:
syms x;
syms n positive integer;
f(x) = atan(x);
P(x,n) = taylor(f, x, 'Order', n);
But there is a Error:
Error using sym/taylor (line 99)
The value of 'Order' is invalid. It must satisfy the function: isPositiveInteger.

Réponse acceptée

Sulaymon Eshkabilov
Sulaymon Eshkabilov le 11 Oct 2019
Modifié(e) : Sulaymon Eshkabilov le 11 Oct 2019
Hi,
Here is the complete answer to your exercise:
syms x
f(x) = atan(x);
syms ii positive integer;
for ii=1:10
P(ii) = taylor(f, x, 'Order', ii);
end
Good luck.
  1 commentaire
Qingyang Zhang
Qingyang Zhang le 11 Oct 2019
Thanks.
So, can I set Order as a variable?

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by