I need to pursue the developement of a variable within a function, but I don't know how.

1 visualizzazione (ultimi 30 giorni)
Yeah hi,
I am within debugging a Programm of mine and need to pursue a variable within a function. I am calling the function with an ode45-solver, while I am integrating x over t. So my problem is, that I'm using a variying stiffness, which I want to pursue over time, to identificate it's developement. My stiffness is a function of x(1) and I'm simply not sure anymore wheter it is following that, through me defined function, or not. Do you guys have any advice for me?
My Code:
[t_num,x_num]=ode15s(@DGL,tspan,q0);
function f=DGL(t,x)
global c_m c_a M om M_stat D
C=[c_m+c_a*sin(om*x(1)) -(c_m+c_a*sin(om*x(1)))
-(c_m+c_a*sin(om*x(1))) 2*c_m+c_a*sin(om*x(1))];
S=[zeros(2,2) eye(2,2)
-M\C -M\D];
a=M\[M_stat;-M_stat];
h=[zeros(2,1);a];
f=S*x+h;
end
I want to observe the value of C(1,1) over time t. Simply putting in a plot-command gives me no reliable result.

Risposta accettata

Torsten
Torsten il 2 Nov 2023
[t_num,x_num]=ode15s(@DGL,tspan,q0);
C11_num = c_m+c_a*sin(om*x_num(:,1));
  6 Commenti
Torsten
Torsten il 3 Nov 2023
Modificato: Torsten il 3 Nov 2023
The solver is starting at t=x=0 therfore C has to be C=[1,-1;-1,1]*c_m.
C at t=0 is [1 -1;-1 2]*c_m.
My question is, wether it is possible that the ode-Solvers are holding the stiffness constant or varying it after there own rules over the span of various of those steps?
Is S the stiffness constant ? If yes: The function DGL is called irregularily by ode15s in order to compute the time derivatives of the functions you solve for. DGL will be called more often when the gradients are steep and less often when the gradients are flat. The aim is to be efficient and precise at the same time. So the computation of S is done as often as necessary in order to keep the error tolerances for the solution (you can change these tolerances RelTol and AbsTol in the options setting for the integrator).

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Tag

Prodotti


Release

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by