How can I use Matlab to control Battery Equivalent Circuit Model of Simulink?
조회 수: 8 (최근 30일)
이전 댓글 표시
Hi,
I want to use Matlab(.m) to change the parameter of Battery Equivalent Circuit Model-short circuit resistance. But I don't know how to achieve it.
Thanks.
답변 (1개)
Xiangchun
2024년 1월 25일
편집: Xiangchun
2024년 1월 25일
Hi Yuyang,
If you question is about how to perform fault modeling for the Battery Equivalent Circuit block from Simscape Battery and change fault model parameters programmatically, here is an example script. It creates a new model, adds the Battery Equivalent Circuit block from Simscape Battery, adds "Internal short" fault to the block, adds timed trigger to the fault, and changes the default shorted resistance parameter to 1.2E-8 Ohm.
clear;
bdclose all;
modelname = 'BatteryModel';
if (exist(strcat(modelname,'.slx')))
delete(strcat(modelname,'*.slx'));
end
open_system (new_system(modelname));
add_block('batt_lib/Cells/Battery Equivalent Circuit','BatteryModel/mycell');
save_system(modelname);
faultableBlocks = simscape.findFaultableBlocks(modelname)
elementPath = simscape.getFaultableElementsInBlock(faultableBlocks)
simscape.addFaultsToBlock(faultableBlocks(1),Element=elementPath(2));
InternalShortFault = [Simulink.fault.findFaults(modelname)]
% Change the trigger type and the fault event time by changing the TriggerType
% and StartTime properties
InternalShortFault.TriggerType = "Timed";
InternalShortFault.StartTime = 30;
% Get the path to the behavior block in the fault model
faultBehaviorPath = InternalShortFault.getBehavior();
% Set the parameter directly in the fault behavior block, using set_param
% as usual.
set_param(faultBehaviorPath,'ShortedResistance','1.2e-8');
This is how the shorted resistance look after exectuing the script.
Best wishes,
Xiangchun
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!