create a signal for a specified duration

8 次查看(过去 30 天)
I would like to do this in simulink. I want to generate a random number for example 0.745 (as a signal) that lasts for 0.5 seconds, then the signal goes down to zero for 2 seconds, and then another random number is generated for example -0.234 (as a signal) which lasts for another 0.5 seconds and then dies down, and the process continues until the simulation ends. The simulation sampling time is 0.1 seconds, so there are signals that are generated at 10hz which my random signal will be added to. (more or less like a step input with random magnitude that dies down after a pre-specified amount of time, and then it comes back on again).
Thank you !

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2013-8-1
Use three blocks
  1. Prod block to multiply the two below blocks
  2. random number block with sample time set to 0.5
  3. repeating sequence stair with sample time set to 0.1 and value to [ones(1,5) zeros(1,20)]
  2 个评论
pemfir
pemfir 2013-8-1
编辑:pemfir 2013-8-1
Thank you I get an error related to discrepancy between sample times of Prod block and the random number block ... The sample time 0.01 of '......Product' at input port 1 is different from the sample time 2 of '.....Random Number' at output port 1.
pemfir
pemfir 2013-8-1
Okay it works if i put a "rate transition" block in front of the random block that converts the sampling time to 0.1 (simulation sampling rate).

请先登录,再进行评论。

更多回答(0 个)

类别

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