How to connect bus signal with different data size using multiport switch?

3 ビュー (過去 30 日間)
And Meng
And Meng 2020 年 12 月 29 日
コメント済み: And Meng 2021 年 1 月 4 日
Hi,
I have two subsystems, and I want to minimized the data size for the signal that is been transfered in between the subsystems. The following figure shows the ideal case. When Constant1 = 1, the first signal with size {1} is transmitted; when Constant1 = 2, the second signal with size {2} is transmitted; Unfortunately, there will be error pop-up regarding to data size mistmatching in this model, which is attached. How could I solve this error or is there other approach to minized this data size. Noted that the constant value should be constant during the simulation.
Regards,
Andy

採用された回答

Mark McBroom
Mark McBroom 2021 年 1 月 4 日
I made a number of changes to your model, most importably was to remove mux blocks. Mux blocks should not be used. Use Vector/Matrix concat blocks to create vectors/matrices, use Bus Creater blocks to create buses.
  1 件のコメント
And Meng
And Meng 2021 年 1 月 4 日
The Vector concat approach works great. In case of the bus creater, I wasn't able to use bus selector on the signal receving end, but I found this: https://www.mathworks.com/matlabcentral/answers/93227-is-it-possible-to-use-a-multiport-switch-to-select-between-several-buses-in-simulink-6-1-r14sp1. Both approachs work good to me. Thank you Mark.

サインインしてコメントする。

その他の回答 (1 件)

Mark McBroom
Mark McBroom 2021 年 1 月 1 日
On the Multi-port switch block, on the Signal Attirbutes tab, check the box "Allow different data input sizes".
  1 件のコメント
And Meng
And Meng 2021 年 1 月 4 日
Thank you for your reply, but if using this approach the bus selector cannot accurately capture the virtual bus signal. Would there be other approach to deal with this data size? I have also attached the model for your reference.

サインインしてコメントする。

製品


リリース

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by