To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016
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
No products are associated with this question.
You must have an initial value for switch2 so that it knows which of the  or  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  is fed forward. Then since  is not equal to 0, the result of the AND will be 0 and your switch will turn "off", and select  next time. Then  is equal to 0 so result of the AND will be 1 and your switch will turn back "on" and select .
Perhaps you should explain what you are trying to do. Also, you might want to look into the latches and flip-flop blocks.
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.
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.