Subsystem with similar functionality as of "Unit Delay"

I want to replace all the 'UnitDelay ' blocks in a model with a subsystem which would have the functionality of 'UnitDelay' block.
I want such a subsystem because the initial condition to the 'Unit Delay' block should be passed from a custom block(for example a constant block or From workspace block) as the initial conditions are changed frequently. I have the initial conditions stored in an array. Any help is appreciated. I am using MATLAB 2020a.
(Also I can not use the old Unit Delay with IC block because of my requirement limitations)

6 Comments

"the initial conditions are changed frequently"
Does this mean the block is reset frequently during a simulation?
Or does this mean the IC of the block changes from from one simulation to the next?
Or something else?
"the initial conditions are changed frequently". I meant to say that I pass the initial conditions from my workspace. The initial conditions are sometimes changed during an experiment. So I want to create a subsystem which would have the functionality of a Unit delay block where the initial conditions would be passed from the workspace. (I plan to pass the ICs as timeseries from a "From Workspace" block)
I'm still not clear on what you want to do with the output from the From Workspace block. Do you just want to delay it by one sample as the simulation runs? I don't understand how a sequence of output from a From Workspace block can relate to IC's of a delay block.
I will try to explain by an example. Lets say I have an initial condition of 5 for a Unit Delay block in my model. After the build of my model during a test run/experiment I change the value of IC from 5 to 6 and observe some change. I record this data. Now coming back to the simulation to study the change, I need the IC to be 6(as this was the last recorded value where I observed a change) instead of 5. I can pass this recorded data (where IC is 6) with the help of a "From Workspace" block. So i need a subsystem where I can pass the IC as a customizable input along with the data signal.
I hope I am clear.
"I change the value of IC from 5 to 6 and observe some change."
Are you changing the value of the IC from 5 to 6 while the simulation is running, or after the simulation with IC=5 is complete and you want to use IC = 6 for the next simulation?
I want to use the IC =6 for the next simulation

Sign in to comment.

Answers (1)

Does the Delay block meet the need? It can accept an IC from an external source and is externally resettable.

4 Comments

No, the delay block does not meet the need in my model. I need to use a Unit Delay.
Use a Unit Delay block.
In the field for Initial Condition enter a variable name, like "InitCond" (without quotation marks).
Assign a value to InitCond in the base workspace, for example
InitCond = 6;
Run the simulation.
Update the value of InitCond in the base workspace, then run the simulation. Etc.
I completely agree with your solution. However the scenario that I explained was an example. I have around 500 UDs in the complete model and it is not a feasible way to change the field of every block. I have already created a script where the value of the new IC is ready to be fed automatically. I need a subsytem to replace the all the UDs in the model with a means to feed the new ICs (which I am thinking to be from a "From Workspace" block, but I am open to any other suggestion).
I still don't understand why the Delay block (doc page link in he original Answer) doesn't fit the need. It can support a delay of 1, i.e., a unit delay and also supports an externally supplied initial condition.

Sign in to comment.

Categories

Find more on General Applications in Help Center and File Exchange

Asked:

on 12 Mar 2023

Commented:

on 13 Mar 2023

Community Treasure Hunt

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

Start Hunting!