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

조회 수: 6 (최근 30일)
Giorgos
Giorgos 2014년 1월 6일
댓글: Giorgos 2014년 1월 7일
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."

채택된 답변

A Jenkins
A Jenkins 2014년 1월 6일
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.

추가 답변 (3개)

Azzi Abdelmalek
Azzi Abdelmalek 2014년 1월 6일
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 2014년 1월 6일
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.
  댓글 수: 2
Azzi Abdelmalek
Azzi Abdelmalek 2014년 1월 6일
Is this an answer or a comment?
Giorgos
Giorgos 2014년 1월 7일
a little of both.

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


Giorgos
Giorgos 2014년 1월 7일
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 :)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by