필터 지우기
필터 지우기

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).

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by