How can I set no initial value for the unit delay block ??

14 views (last 30 days)
Hello, Im trying to make a simulink model for a project have. What Im trying to do is to control the values from sxitch2 based on the values imported from switch1, the function in the block has the following code:
function y =rounding(x)
mintol=0.5;
if abs(x)<mintol
y=0;
else
y=x;
end
end
What I have noticed is that the time delay blocks initial value is zero "0" thus every new value that enters gets set to zero. Thus not able to lock the switch. I have tried to remove the unit block but I get the following error message:
"Simulink cannot solve the algebraic loop containing 'test/MATLAB Function2' at time 0.0 using the TrustRegion-based algorithm due to one of the following reasons: the model is ill-defined i.e., the system equations do not have a solution; or the nonlinear equation solver failed to converge due to numerical issues. To rule out solver convergence as the cause of this error, either
  1. switch to LineSearch-based algorithm usingset_param('test','AlgebraicLoopSolver','LineSearch')
  2. reducing the VariableStepDiscrete solver RelTol parameter so that the solver takes smaller time steps.If the error persists in spite of the above changes, then the model is likely ill-defined and requires modification."

Accepted Answer

A Jenkins
A Jenkins on 6 Jan 2014
You must have an initial value for switch2 so that it knows which of the [111] or [000] to start with. Therefore you must have an initial result of your AND block, and an initial value of your unit delay blocks. (You could move and combine the unit delay right before your switch2 if that helps you think about it.)
That said, your values are not flip-flopping because of your initial value. Imagine you initially start with the switch2 "on" so that [111] is fed forward. Then since [111] is not equal to 0, the result of the AND will be 0 and your switch will turn "off", and select [000] next time. Then [000] is equal to 0 so result of the AND will be 1 and your switch will turn back "on" and select [111].
Perhaps you should explain what you are trying to do. Also, you might want to look into the latches and flip-flop blocks.

More Answers (3)

Azzi Abdelmalek
Azzi Abdelmalek on 6 Jan 2014
I'am not following you, the initial value of the unit delay block is used, only at the start of your simulation, and you can set it to whatever you want.

Giorgos
Giorgos on 6 Jan 2014
The thing is,
that the feedback goes to the unit block, initiating a zero value and thus over-writing the current value, causing the switch to go on and off instead of locking on one value.
As you can see from the attached graph the values after the time-delay block alternate instead of obtaining a fixed value.
Do you know why this happens?
I have attached the input scope graph as also the graph after the function block.

Giorgos
Giorgos on 7 Jan 2014
Jenkins Thanks for your replay,
Every thing is more clear now. As you have noticed im new to simulink, and as a noobie :) every thing is done the hard way.
Thanks again :)

Community Treasure Hunt

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

Start Hunting!