Override Unit Delay block outptut

조회 수: 3 (최근 30일)
Shouvik Das
Shouvik Das 2011년 12월 10일
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
Walter Roberson
Walter Roberson 2011년 12월 12일
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.
Shouvik Das
Shouvik Das 2011년 12월 12일
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.

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

채택된 답변

Fangjun Jiang
Fangjun Jiang 2011년 12월 12일
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
Fangjun Jiang
Fangjun Jiang 2011년 12월 13일
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
Fangjun Jiang 2011년 12월 13일
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.

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2011년 12월 12일
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.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by