matlab function问题。

function [PWM5,PWM6,PWM1,PWM8,PWM9,PWM2] = fcn(soc1,soc2,p6,p7)
soc1=soc1*1000;
soc2=soc2*1000;
soc1=int32(soc1);
soc2=int32(soc2);
PWM5 = 0; %未开始均衡时,电池1、2、3同时接入
PWM6 = 0;
PWM1 = 0;
PWM8 = 1;
PWM9 = 0;
PWM2 = 0;
Amax = max(soc1,soc2);
Amin = min(soc1,soc2);
for (Amax - Amin ~= 0) %判断均衡开始条件
{
if (Amax == soc1)
{
PWM5 = p6; %选择电池1接入
PWM8 = p6;
PWM6 = p7;
PWM1 = p6;
PWM9 = p7;
PWM2 = p6;
}
else
{
PWM5 = p7; %选择电池2接入
PWM8 = p7;
PWM6 = p6;
PWM1 = p6;
PWM9 = p6;
PWM2 = p6;
}
end
end
PWM5 = 0; %均衡结束,电池1、2同时接入
PWM6 = 0;
PWM1 = 0;
PWM8 = 1;
PWM2 = 0;
end
出现double数据类型错误问题。

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!