Need to make graph from Multiple Simscape Runs
조회 수: 2 (최근 30일)
이전 댓글 표시
I am running a simulation of a pilot operated hydraulic valve built on simscape down to the component level.
I want to make a single graph of pressure drop vs flow across various different pilot valve restrictions, something like below, where each colour is a different run in simscape:
I am not the most experienced with Matlab coding, I have tried to export results to an Excel then manually make them from there but I would Ideally like to do this all within Matlab
댓글 수: 0
답변 (1개)
Cris LaPierre
2024년 10월 2일
I would suggest using the Simulink Data Inspector.
In your Model Settings under Simscape, set the following Data Logging settings
After running your first simulation, open the Data Inspector and give the simulation a meaningful name (200 Hz here). Expand the component tree to select the signals to plot. Here, that is source voltage and capacitor voltage (plotted against time here).
Now return to your model, change a parameter, rerun the simulation, and open the data inspector. The new simulation results are displayed (give them a meaninful name), and the previous simulation is move to the Archive section. Browse the Archive structure to add selected signals to the plot.
You can change the line format by clickin on the colored line to the right of the signal and choosing a new color and line style.
It sounds like you want to plot one signal against the other in an XY plot. You can do that by selecting the appropriate icon at the top. You wil then need to specify the X and Y signals.
댓글 수: 2
Cris LaPierre
2024년 10월 2일
Another option is to do this all within MATLAB. You still need to set the Data Logging settings to log the data. You do not need to check the Simulation Data Inspector option.
Make note of the Workspace Variable Name. You can change this, but by default it is simlog.
Make note of one other setting under Data Import/Export - is 'Single simulation output' selected? If so, what is the variable name? By default, this is out.
If it is selected, you will find your data in the MATLAB Workspace under out.simlog, otherwise it will just be under simlog.
Note that the simulation results do not appear in the Workspace, but you can still access them in MATLAB.
Tab completion is helpful here. Here is code that would recreate the plot above.
Vs = out.simlog.AC_Voltage_Source.v.series;
Vc = out.simlog.Capacitor.vc.series;
plot(Vs.time,Vs.values,'b-',Vc.time,Vc.values,'r-')
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Logging에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!