Update Value from Workspace in Simulink During Simulation

50 Ansichten (letzte 30 Tage)
umichguy84
umichguy84 am 2 Jan. 2018
Kommentiert: umichguy84 am 8 Jan. 2018
In short is there a way/block that uses a workspace variable for it's output?
For context, I have a simulation of a train where there are multiple cars on the train. The inputs to this model are an array of buses. Each vehicle has over 100 inputs. So when testing we create a test stand that has the 20 or 30 most common controls for the lead vehicle, and the rest are set to a default value and don't change. However, sometimes during testing you realize you need to modify a different input or a input on a different vehicle. I was trying to work out a way of being able to modify one of those inputs without having to stop the simulation and add it in (can takes up to 1 minute to stop and start the model).
The plan was a variable that is read from the workspace, and then any inputs in the test stand are read in afterward. Therefore, the inputs in the test stand have priority over the workspace values. The issue is I cannot workout a way of reading in a variable from the workspace that can be changed during simulation. I have tried:
  • A constant block with a workspace variable (which doesn't change values during simulation)
  • A matlab function using the code below,(this does work but the performance impact is severe)
function y = readVehicleInputsBus(Z_VehicleInputsBusInit)
coder.extrinsic('evalin')
y = Z_VehicleInputsBusInit;
y = evalin('base','Z_VehicleInputsBusInit');
Is there a better way of accomplishing this?

Antworten (1)

Malhar Ashtaputre
Malhar Ashtaputre am 2 Jan. 2018
Hello,
The variables in MATLAB workspace are not updated in runtime(without stopping simulation) in simulink.
The another way to change variables in runtime(without stopping simulation) is to use Dashboard in Matlab simulink. Check the following link for information about Simulink Dashboard.
https://in.mathworks.com/help/simulink/ug/tune-and-visualize-your-model-with-dashboard-blocks.html
You can also create a custom made GUI for simulink using event listeners (event listeners is a bit complex), i suggest to use Dashboard method instead which is very easy and doesn't take much time.
  1 Kommentar
umichguy84
umichguy84 am 8 Jan. 2018
Hello, Maybe it's my misunderstanding, but Simulink Dashboard appears to be another way of creating a test stand. So I would have to add every input for every vehicle in my train for this to work. This wouldn't really solve my issue.
I'm looking for something that allows me to change all my inputs, without having to create a "control" or dashboard in this case ,for every control and every vehicle on my train. Let me know if I misunderstood. Cheers

Melden Sie sich an, um zu kommentieren.

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by