Click here to Skip to main content
15,922,584 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
MATLAB HELP !!! TAYLOR SERIES?
i have to write a matlab function that accepts the following inputs and yields the following
inputs:
1)f function, inputted as a string 'f'
2)a center of the taylor series
3)n degree of the taylor polynomial
output:
1) P n-th degree taylor polynomial off centered at a


i need the function to output a P nth degree taylor polynomial centered at a
here is the code i have , it works almost perfect but im not sure how to get the derivatives of the functions at "a" with out compromising my (x-a) term...
from what i see the diff(f,k) computes the kth derivative of f, but can not plug
in the a. looks my code will require another matlab function that will do the plugging any suggestions?

function [P] = mytaylor(f,a,n)
f=sym(f);
syms x ;
terms=0;
for k=0:n
fk=diff(f,k);
terms = terms + fk*(x-a)^(k)/factorial(k);
end
P=terms;
Posted
Updated 20-Apr-14 2:49am
v2
Comments
Andreas Gieriet 20-Apr-14 8:28am    
What exactly is the problem? "...wont work..." does not help.
Say what exactly is not working as expected. Please allow the audience to help you. Nobody will take the burdon to fire up Matlab for you and try it out for you (unless he is very much a Philantrope ;-)). Allow for quick help.
Cheers
Andi
Joshua Rocky Lizardi 20-Apr-14 8:49am    
i worked on it , sry about the last question all i need now is away to plug in "a"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900