Filter löschen
Filter löschen

Using ode45 to integrate

2 Ansichten (letzte 30 Tage)
E
E am 21 Mär. 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 Kommentar
Jan
Jan am 21 Mär. 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);

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Jan
Jan am 21 Mär. 2013

Community Treasure Hunt

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

Start Hunting!

Translated by