Tapped delay function with varying size in Simulink
Show older comments
Hello
I wanted to know if there a way to give the "Number of delays" externally in the tapped delay function.
My idea is, the user should be able to connect an input port and this port gives the number of delays that the tapped function needs to have. So as to make it dynamic and not static where I set the number of delays during development phase itself.
(Setting parameters of the tapped delay function in simulink externally)
Thanks

Accepted Answer
More Answers (1)
Oscar de la Hoz
on 27 Nov 2022
0 votes
Hi Swati,
Try to use one variable in "Number of Delays" field.
In my case, I wanted "Number of Delays" to be equal to Simulation Time. So first I wrote the variable:

After that, create a Matlab function externally, with the algorithm of your input value and use Callbacks (in Model Explorer) to run the Matlab function (in my case, the variable was created when the model was run, so I used the function in InitFnc):
Matlab Script saved as "StopTime_InitF"
StopTime_1 = double(0);
My_model = get_param(0, 'CurrentSystem');
stop_time_as_str = get_param(My_model, 'StopTime');
StopTime_1 = str2double(stop_time_as_str);

The function will modify "StopTime_1" variable in Model Workspace just before running the model.
Then, "Number of Delays" has been modified externally.
I hope you can adapt this to your case.
Regards,
Oscar.
1 Comment
Vu Hoang Thang Chau
on 18 Jan 2024
Hi Oscar,
I have a similar issue and worked this out before.
I think this mostly works if you stay with simulation or C code generation.
My application requires HDL generation and it is a pain to regenerate this all over again all the time using this method.
I'm using the Memory and Selector method as above.
Regards,
V.
Categories
Find more on General Applications in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!