MATLAB Answers

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

2 ビュー (過去 30 日間)
Ankit
Ankit 2021 年 7 月 19 日
コメント済み: Fangjun Jiang 2021 年 7 月 21 日
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.

採用された回答

Fangjun Jiang
Fangjun Jiang 2021 年 7 月 20 日
  5 件のコメント
Fangjun Jiang
Fangjun Jiang 2021 年 7 月 21 日
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.

サインインしてコメントする。

その他の回答 (0 件)

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by