taylor series method expansion
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I am using the following code for taylor series
function [T,Y] = taylor(f,a,b,ya,m)
h = (b - a)/m;
T = zeros(1,m+1);
Y = zeros(1,m+1);
T(1) = a;
Y(1) = ya;
for j=1:m
tj = T(j);
yj = Y(j);
D = feval('df',tj,yj);
Y(j+1) = yj + h*(D(1)+h*(D(2)/2+h*(D(3)/6+h*D(4)/24)));
T(j+1) = a + h*j;
end
At command prompt i am giving the values as follows and getting error
>> syms x y;
>> f=4*x^3+1
f =
4*x^3 + 1
>> taylor(f,0,1,1.5,4)
Error using sym/taylor (line 99)
The value of 'x' is invalid. It must satisfy the function: @(x)isvector(x)&&isAllVars(x).
9 Commenti
Walter Roberson
il 19 Set 2018
Well you could if you had a variable name to take the derivative with respect to, and you had some reason for D(1) being different from D(2), D(3) etc.
Risposte (1)
Walter Roberson
il 18 Set 2018
You are somehow invoking the symbolic toolbox taylor routine instead of your own. Make sure that you match file name with function name and that your path is correct to prioritize your own function.
0 Commenti
Vedere anche
Categorie
Scopri di più su Assumptions in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!