フィルターのクリア

Using ode45 to integrate

2 ビュー (過去 30 日間)
E
E 2013 年 3 月 21 日
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
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 件)

Jan
Jan 2013 年 3 月 21 日

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by