MATLAB Answers

Override Unit Delay block outptut

2 views (last 30 days)
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
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.
Shouvik  Das
Shouvik Das on 12 Dec 2011
Walter! I agree with you. May be my way of asking was not clear enough. The Change shall only be for the purpose of simulation and in a dynamic way (using automation). Hence I do not want to induce a change by manually removing the Feedback loop, in which case I shall be replacing them with inputs and that shall end up in many more changes to the model like IO specifications, counts etc.
It is only temporarily that I want to break the feecback loop and dynamically through automation.

Sign in to comment.

Accepted Answer

Fangjun Jiang
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
Fangjun Jiang
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.

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 12 Dec 2011 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.

Community Treasure Hunt

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

Start Hunting!