Can someone explain to me how can i import a vector from matlab to simulink using the in1 block?

조회 수: 19 (최근 30일)
I, i am pretty new in simulink and i would like to know how can i import a vector from matlab to simulink by using the in1 block? I would also like to separate the values of the vector by using a bus selector block, similarly to what they did in this picture.
Thank you very much for your help

답변 (1개)

Nithin Kumar
Nithin Kumar 2023년 4월 25일
Hi Jorge,
I understand that you are trying to export a vector from MATLAB to Simulink and then separate the values of the vector by using a Bus Selector block.
Kindly follow the following steps to export a vector from MATLAB to Simulink:
  • Create a vector in MATLAB that you want to export to Simulink.
  • In Simulink, add an In1 block to your model. Then, open its parameter dialog by double-clicking on it.
  • In the parameter dialog box, set the “Datatype” parameter to “Inherit: auto”. This will allow the block to inherit the data type of the signal connected to its port.
  • Connect the output of the In1 block to the input of the block in your Simulink model that you want to use the vector with.
  • In the MATLAB command window, type the following command to set the input of In1 block:
Set_param( modelName/In1,value,vector);
In order to separate the values of the vector by using a Bus Selector block, follow the below steps:
  • Add a Bus Creator block to the Simulink model. Double-click on it and create a bus object that has the same number of elements as the vector you want to separate.
  • Add a Bus Selector block to the model and connect the output of the Bus Creator block to the input of the Bus Selector block.
  • Open the parameter dialog box of Bus Selector by double-clicking on it and select the elements of the bus object that correspond to the elements of the vector you want to separate (i.e., If the first element of the vector corresponds to the “A” element of the object, select “A” in the Bus Selector block’s parameter dialog box).
  • Add an appropriate output block for each of the separated signals and connect each one to its respective Bus Selector output port and Run the Simulation.
For more information regarding In1 block and Bus Selector blocks, refer the folowing links:
I hope this answer will be helpful.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by