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