Borrar filtros
Borrar filtros

Change vector size in Simulink

11 visualizaciones (últimos 30 días)
Fabian
Fabian el 28 de Nov. de 2012
Hi,
A few times now, i encountered the situation that i want to change the size of an vector. Maybe i start with an example(see picture): http://www.bilder-upload.eu/show.php?file=bdbf1e-1354099408.png I have a mechanism that performs a certain action on every item in a vector. I have to use this a lot, so i made an generic library-subsystem from it. This bloc has an input for the vector and one for the number of relevant signals (to save calcualtion time). The Subsystem only accepts a vector with the size 10, but doesn't care about the lower 7 values in this case.
Now i have to use this bloc a lot with variing number of input signals. Is there a way to increase the size of a vector (here size 3) to match the input of the procesing bloc, without using a MUX everytime? The new lines in the vector can be filled with anything, as they will be ignored anyway.
Something like a bloc that has one input for the vector to be changed and one for for the new size (So either crop or expand it)
If you read this, thanks for you attention

Respuesta aceptada

Ryan G
Ryan G el 28 de Nov. de 2012
Editada: Ryan G el 28 de Nov. de 2012
You can use a gain block utilizing matrix multiplication instead of element-wise that has a vector, such as:
[eye(3) zeros(7,3)' ]'
Depending on the dimensions. Essentially the eye(3) maintains the original inputs and the zeros pads the rest. For a 4 element vector it would look like:
[eye(4) zeros(6,4)' ]'
Hopefully this makes sense. I'm not sure if there is an easier way but there might be.

Más respuestas (0)

Categorías

Más información sobre General Applications en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by