MATLAB Answers

Repeat a time based signal in Simulink (not using *.m script) / during Start of simulation based on number of repetitions

7 views (last 30 days)
Ankit
Ankit on 19 Jul 2021
Commented: Fangjun Jiang on 21 Jul 2021
I am looking for a way to repeat a time based signals "n" times in Simulink as soon as I run the simulation.
Just for reference I am adding the x,v values for the below plot which is being used currently in 1-D Lookup table.
x = [0, 11, 15, 23, 25, 28, 49, 61, 85, 93, 96, 117, 143, 155, 163, 176, 185, 188, 206, 210, 218, 220, 223, 244, 256, ...
280, 288, 291, 312, 338, 350, 358, 371, 380, 383, 401, 405, 413, 415, 418, 439, 451, 475, 483, 486, 507, 533, 545, 553, 566, ...
575, 578, 596, 600, 608, 610, 613, 634, 646, 670, 678, 681, 702, 728, 740, 748, 761, 770, 773, 800, 841, 891, 899, 968, 981, ...
1031, 1066, 1096, 1116, 1126, 1142, 1150, 1160, 1180];
v = [0, 0, 15, 15, 10, 0, 0, 32, 32, 10, 0, 0, 50, 50, 35, 35, 10, 0, 0, 15, 15, 10, 0, 0, 32, ...
32, 10, 0, 0, 50, 50, 35, 35, 10, 0, 0, 15, 15, 10, 0, 0, 32, 32, 10, 0, 0, 50, 50, 35, 35, ...
10, 0, 0, 15, 15, 10, 0, 0, 32, 32, 10, 0, 0, 50, 50, 35, 35, 10, 0, 0, 70, 70, 50, 50, 70, ...
70, 100, 100, 120, 120, 80, 50, 0, 0];
Just for an example i want to duplicate the above signals 3,4 .. n times!
With repmat it is possible to duplicates the value but x values should be monotonically increasing! Is there any built in functions which can be used.
P.S: I already have working solution which I created as a function. But I am looking for a simulink model with library blocks.

Accepted Answer

Fangjun Jiang
Fangjun Jiang on 20 Jul 2021
  5 Comments
Fangjun Jiang
Fangjun Jiang on 21 Jul 2021
Read the comment again. Multiply the outputs of the Repeating Sequence block and the Step block would implement this. If N is an external input ("user input" implies block parameter dialog input), you can multiply this external input with the Time Period (T, e.g. 1200 seconds). Use a Clock block to compare the simulation time with N*T, and then do the switch using the True or False output.

Sign in to comment.

More Answers (0)

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by