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

1 visualizzazione (ultimi 30 giorni)
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!

Risposte (1)

Walter Roberson
Walter Roberson il 21 Mar 2019
See the documentation for odeFunction . In particular, follow the flow of calls that is used in the first example.
  6 Commenti
Marlene Dehn
Marlene Dehn il 21 Mar 2019
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 il 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.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by