필터 지우기
필터 지우기

Change vector size in Simulink

조회 수: 11 (최근 30일)
Fabian
Fabian 2012년 11월 28일
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

채택된 답변

Ryan G
Ryan G 2012년 11월 28일
편집: Ryan G 2012년 11월 28일
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.
  댓글 수: 1
Fabian
Fabian 2012년 12월 4일
Thanks, works like a charm

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 General Applications에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by