How to change the drive cycle in Simulink through script?

7 Ansichten (letzte 30 Tage)
清源
清源 am 25 Sep. 2023
Kommentiert: 清源 am 1 Okt. 2023
Hello!
I'm currently using Virtual Vehicle Composer APP to build a simulink model to evaluate the energy comsumption of a electric car. However, I need to use my own drive cycle to run the estimation which is not standard as predefined in the MATLAB Drive Cycle Data APP. And I also need to use the log data to do further optimization so I have to write some scripts to perform the estimation and get the data at the same time.
The script generated by Virtual Vehicle Composer has been shown below, I want to know if I can use any functions or statements to change this original drive cycle to my own drive cycle which is from workspace or from .mat file.

Akzeptierte Antwort

Nishan Nekoo
Nishan Nekoo am 26 Sep. 2023
Hi,
Looking into the setParamforManeuverAndDriver.m function provides some clues on how this can be done. On line 24 of that file in \VirtualVehicle\Scripts, there is the following line that sets the Drive Cycle to 'Wide Open Throttle':
in=in.setBlockParameter(ManeuverMaskPath,'cycleVar',ManeuverOption);
ManeuverMaskPath is the path to the DriveCycleSource block in your model, mine for example was:
ManeuverMaskPath = 'ConfiguredVirtualVehicleModel/Scenarios/Reference Generator/Reference Generator/Reference Generator/Drive Cycle'
You can override the drive cycle in the 'TestScript' with a .mat file by doing something like the following:
in(1)=in(1).setBlockParameter(ManeuverMaskPath,'cycleVar','.mat, .xls, .xlsx or .txt file');
in(1)=in(1).setBlockParameter(ManeuverMaskPath,'fileVar','driveCycle.mat')
or with a variable by doing something like the following:
in(1)=in(1).setBlockParameter(ManeuverMaskPath,'cycleVar','Workspace variable');
in(1)=in(1).setBlockParameter(ManeuverMaskPath,'wsVar','driveCycle')
I identified variable names like 'fileVar' and 'wsVar' by right clicking on the DriveCycleSource block and selecting Mask > View Mask.
I did not try this myself so there might be other things you need to set to get this working, but this should help you get started.

Weitere Antworten (0)

Kategorien

Mehr zu Powertrain Blockset finden Sie in Help Center und File Exchange

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by