Using ode45 to integrate
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
Jan
2013-3-21
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);
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!