Simulink Model

11 visualizaciones (últimos 30 días)
Meagan
Meagan el 16 de Mayo de 2011
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 comentario
Jarrod Rivituso
Jarrod Rivituso el 16 de Mayo de 2011
Does your model contain any algebraic loop warnings?

Iniciar sesión para comentar.

Respuestas (1)

Seth Popinchalk
Seth Popinchalk el 17 de Mayo de 2011
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.

Categorías

Más información sobre Simulink Functions en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by