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
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

类别

Help CenterFile Exchange 中查找有关 Simscape Battery 的更多信息

标签

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by