Override Unit Delay block outptut
2 views (last 30 days)
Show older comments
Product: Simulink Problem Statement: Complex feedback loops implying usage of Unit Delay Block. At certain simulation frame calculation of required values for test generation is becoming complex. Is there a way to override the Unit Delay block output without changing the model (as I am not allowed to do so) rather by using set_param. I am using cvdata/sim/cvhtml combination for my simulation. I tried extracting all the assocaited aparameter sfor Unit Delay using
get_param(gcb,'ObjectParameters');
but was not able to find a suitable parameter to use owing to lack of help information on each parameters.
Kindly help me out if this approach is possible.
4 Comments
Walter Roberson
on 12 Dec 2011
Some people would define using set_param as "changing the model". Whether you change the model by set_param or by clicking on the block and changing its parameters, the model is still changed.
Accepted Answer
Fangjun Jiang
on 12 Dec 2011
No, you can't. set_param() is used to change the "Parameters" of the model or block. It can not be used to change the dynamic output of a block.
What you want to do sounds like fault injection for debugging purpose. It's like cut a line on a circuit board and feed a different signal temporarily. I am afraid you can't use set_param() for that.
You might have to put this fault injection capability into your design. In your Stateflow chart, define a condition and a third variable. Use this condition and variable to "cut the line".
If ConditionIsTrue
op=ThirdVariable;
else
op=in+constant;
end
4 Comments
Fangjun Jiang
on 13 Dec 2011
In that case, I would suggest you breaking that unit delay feedback loop and adding some blocks. It's easier than modifying the statechart. What you imaged is impossible. Even using set_param() is going to modify the model anyway.
Fangjun Jiang
on 13 Dec 2011
If you don't want to do manual change, you can use script or function to make the change. Some key functions are find_system(), add_block(), delete_line(), add_line(), etc.
More Answers (1)
Walter Roberson
on 12 Dec 2011
http://www.mathworks.com/help/toolbox/simulink/slref/f23-20073.html#discrete_lib_blkparams and scroll to the very near the end of that subsection (it is a big subsection) to find a description of all of the parameters for the Unit Delay block. In particular the Initial Conditions (hold period) of the block is controlled by the X0 parameter.
However, it is not clear that you want to change the delay. You speak of changing the output, so it sounds like at the particular point you want to substitute new outputs for the current outputs, and you want to do it at the particular point so that you get the right timing attached to the values. If this is what you want to do, then there is no way to do that by using set_param on the Unit Delay block. Instead, between the Unit Delay block and the block(s) that use the output, you should interpose a MATLAB Function block that examined the input and timestep and determined the appropriate output. If the output of the Unit Delay block is going to multiple other blocks, then Yes, you would end up having to change the attachment points for multiple blocks.
0 Comments
See Also
Categories
Find more on Simulink Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!