Assign vectors from MATLAB workspace structure to Simulink Model inports
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Masoom Kumar
el 28 de Mayo de 2018
Comentada: Masoom Kumar
el 29 de Mayo de 2018
I need help with running a Simulink model with the data from MATLAB workspace contained in structures. Below is a very simplified use-case of what I would like to do
Use Case :
I have a struture in MATLAB workspace called "data", and it has two fields x, and y which are vectors. I have a simulink model with two inports named x and y. I would like to dynamically assign to data from the structure "data" to the Simulink inports and run the model
The above use case is a very simplified scenario. The model that I intend to use can have 100 inports, and thus I do not want to use "From Workspace" block, as it would be impractical for me to add 100s of them
How can I handle such a situation in Simulink. I am a little more than a beginner in MATLAB and Simulink. So, a detailed answer would help me a lot
0 comentarios
Respuesta aceptada
TAB
el 28 de Mayo de 2018
Editada: TAB
el 28 de Mayo de 2018
One of the format is like below:
dataIn.time = [0:10]'; % Depend upon your sample time and stop time
dataIn.signals(1).values = data.x; % x values at each step
dataIn.signals(1).label = 'x'; %Inport name
dataIn.signals(2).values = 'data.y'; % y values at each step
dataIn.signals(2).label = 'y'; %Inport name
Now enter dataIn in Configuration Parameters > Data Import/Export > Load from workspace > Input
3 comentarios
TAB
el 29 de Mayo de 2018
dataIn.signals(2).values = 'data.y';
--> You have assigned string here. Remove the single quote.
Más respuestas (0)
Ver también
Categorías
Más información sobre Programmatic Model Editing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!