Update Value from Workspace in Simulink During Simulation
51 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(1 个)
Malhar Ashtaputre
2018-1-2
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.
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!