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

1 回表示 (過去 30 日間)
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.

採用された回答

Torsten
Torsten 2023 年 11 月 2 日
[t_num,x_num]=ode15s(@DGL,tspan,q0);
C11_num = c_m+c_a*sin(om*x_num(:,1));
  6 件のコメント
Torsten
Torsten 2023 年 11 月 3 日
編集済み: Torsten 2023 年 11 月 3 日
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).
Johannes Graf
Johannes Graf 2023 年 11 月 3 日
THANK YOU! That mere text saved my day!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by