필터 지우기
필터 지우기

How to make a matrix with one unknown variable, that can be in a for loop and can be used in ODE45

조회 수: 1 (최근 30일)
Hi, at the moment I have the following code. I think the problem is the matrix B is a symbolic funtion, and not a anonymous function, but I can't make an anonymous function to work within a loop.
syms t x u
l=50;
v = 50;
N = 5;
for n = 1:N
for c = 1:N
B(n,c) = sin((n*pi*v*t)/l) * sin((c*pi*v*t)/l);
end
end
T = [t,t,t,t,t];
Td = [diff(t,t) diff(t,t) diff(t,t) diff(t,t) diff(t,t)];
tspan=[1,0.1,10];
xinit=zeros(1,2*N+2);
z=[T u Td diff(u,t)]';
[t,z]=ode45(B*z,tspan,xinit);
It's my first time using the ode45, so I'm not sure I'm using that one correct either.
So now I'm trying the mathworks-community, so I really hope you guys can help!

답변 (1개)

Walter Roberson
Walter Roberson 2019년 3월 21일
See the documentation for odeFunction . In particular, follow the flow of calls that is used in the first example.
  댓글 수: 6
Marlene Dehn
Marlene Dehn 2019년 3월 21일
Yeah, the thing is we need to find a N, that is good enough to erased the infinite summation, that is why we need the for loop from 1:N, so the N can be a number from 1-infinite. But when we have the solution, we can figure out what the N needs to be through a convergence-analysis.
Walter Roberson
Walter Roberson 2019년 3월 21일
It is not at all obvious to me that you can justify a finite truncation. That would require that the Tn functions are decaying with increasing n, which is not an obvious conclusion. I can see that it might happen because of the increasing (n*pi/l)^4 multiplier in the first term could force the Tn smaller and smaller to match the right hand side, but the infinite summation makes things difficult.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by