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!
0 个评论
回答(1 个)
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 个评论
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 Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!