Borrar filtros
Borrar filtros

Using ode45 to integrate

2 visualizaciones (últimos 30 días)
E
E el 21 de Mzo. de 2013
Hi.
I'm trying to integrate
dfN/dx= summation(n=1 to N)[{−1^(n+1)}*x^n)/n!] with the conditions , y(0) = 1, x = 0..5, N = 1..10
So far I have tried to create a function file:
function fun = fun1(x,y,N)
fun=0;
fun=fun+(((-1).^(N+1)).*(x.^N))./(factorial(N));
end
And I call it in my script file:
N=1:10;
for k=1:length(N)
[p1x,p1y]=ode45(fun1,[0,5],1,[],N(k))
y_fun1=p1y(length(p1y))
end
I keep getting the error message that N is undefined! I have been working on this for a while now, but I've never worked any examples with the summation and it's throwing me off. HELP!!
  1 comentario
Jan
Jan el 21 de Mzo. de 2013
What is the difference between:
fun = 0;
fun = fun+(((-1).^(N+1)).*(x.^N))./(factorial(N));
and
fun = ((-1 .^ (N+1)) .* (x .^ N)) ./ factorial(N);

Iniciar sesión para comentar.

Respuestas (1)

Jan
Jan el 21 de Mzo. de 2013

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by