フィルターのクリア

How to change the drive cycle in Simulink through script?

7 ビュー (過去 30 日間)
清源
清源 2023 年 9 月 25 日
コメント済み: 清源 2023 年 10 月 1 日
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.

採用された回答

Nishan Nekoo
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 件)

カテゴリ

Help Center および File ExchangeVirtual Vehicles についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by