Simulink Model

조회 수: 11 (최근 30일)
Meagan
Meagan 2011년 5월 16일
I have a feedback loop in Simulink around an Embedded MATLAB block. My code in the block looks like this:
initvel=feedback(3)
dt=.02;
deltvel=commandvelocity-initvel;
accel=max(min(deltvel/dt,maxaccel),maxdecel)
updatevel=accel*dt
finalvel=initvel+updatevel
When I run my model, I look at the time and the values being updated. My output looks like this:
t =
0
initvel =
0
accel =
40
updatevel =
0.8000
finalvel =
0.8000
t =
0
initvel =
0
accel =
40
updatevel =
0.8000
finalvel =
0.8000
t =
0
initvel =
3.6029e+015
accel =
-20
updatevel =
-0.4000
finalvel =
3.6029e+015
I have an initial condition block in the feedback loop that sets the initial velocity to 0. I have two problems:
1. Why does it run through the simulation at time=0 several times?
2. Why does the initial velocity jump to 3.6e15?
  댓글 수: 1
Jarrod Rivituso
Jarrod Rivituso 2011년 5월 16일
Does your model contain any algebraic loop warnings?

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

답변 (1개)

Seth Popinchalk
Seth Popinchalk 2011년 5월 17일
Models will evaluate blocks multiple times in the same time step when there are algebraic loops. Turn the algebraic loop diagnostic to Warning so you can see the message about what blocks are involved in the loop. You can also use the Simulink debugger with the command ashow to highlight the algebraic loop(s).
The reason the output of the block might change when evaluated at the same time step is that the algebraic loop solver is searching for a solution that satisfies the algebraic loop. This uses Newtons method to change the algebraic variable and hopefully find the solution. The solution from the last step is the starting point for the search in the next step. This can cause a change in the answer to something like 3.6e15 if the math in the model computes this value during the search.

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by