How to change the drive cycle in Simulink through script?
7 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
Nishan Nekoo
2023-9-26
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.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!