How to make a matrix with one unknown variable, that can be in a for loop and can be used in ODE45
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Walter Roberson
le 21 Mar 2019
See the documentation for odeFunction . In particular, follow the flow of calls that is used in the first example.
6 commentaires
Walter Roberson
le 21 Mar 2019
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.
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!