Filter löschen
Filter löschen

How to initialize the size of a Simulink vector with a constant block

20 Ansichten (letzte 30 Tage)
Jay Land
Jay Land am 8 Apr. 2013
I have a nx1 length rand vector being used in a Simulink model. I would like to be able to change its length, n using a constant block. I am new to Simulink so this is probably a pretty basic question but I can't get it to work. I can create the vector as a constant with rand(10,1) for example or I can set N=10 in the Matlab workspace and use rand(N,1) as the constant but I want to be able to change N on the block diagram.

Antworten (1)

Kaustubha Govind
Kaustubha Govind am 22 Apr. 2013
If 'N' changes during simulation, it essentially means that the size of the signal (Nx1) changes during simulation. These types of signals are called Variable-size signals in Simulink and must be bounded (ie. you need to specify an upper bound for N). I can't think of an existing block that lets you output a variable-size signal with values rand(N,1), but you can easily implement such a block using a MATLAB Function block. Please also remember to configure the block to output a variable-size signal.

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by