Vector to matrix using assignment - Simulink
Show older comments
Simple one I guess : I would like to get from a Vector (1x8) to a Matrix (2x4) using index selection from one or two external constant block(s).
I tried using the assignment block but I guess I don't really understand how to use it here. Expected output is in yellow.

Accepted Answer
More Answers (2)
Fangjun Jiang
on 28 Apr 2021
0 votes
Your output is a 2x4 matrix. Using Assignment block, you could either
Provide a scalar value in U, assign multiple elements of the 2x4 matrix
Or, Provide the same size (2x4) value in U, assign seletive elements of the 2x4 matrix.
I couldn't figure out a way to do what you want, which is reshape plus shuffle.
The easiest approach is to use a MATLAB Function block. It just needs one line of code.
Y=U(Idx1)
Categories
Find more on Array and Matrix Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

