필터 지우기
필터 지우기

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 CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by