clear
clc
H=input('请输入谐波滤波最大频率H=');
N=input('请输入单调谐滤波器个数N=');
w1=zeros(N+1,5);
for k=1:N
prompt = {' 谐波次数 h ' ,' h次谐波电流 Ih' , ' 实际运行电压 U1',...
' h次谐波电压含有率 HRUh' ,' 品质因数 q','运行电压上限 U1m' };% 是一个元胞矩阵: 提示字符串
defaults = {'2','11.3','35',...
'0.1','45','70' } ;% 默认值—— —基本组分是元胞
dlg_title = ' 通用滤波器参数计算' ;% 给输入对话框加一个标题
num_lines= 1;% 每个元胞元素占的行数
answer= inputdlg(prompt,dlg_title ,num_lines,defaults ,' on') ;% 产生输入对话框, 并返回用户输入到元胞矩阵answer
w=zeros(1,4);
i=1;
h =str2double(answer{i});i=i+1;
Ih=str2double(answer{i});i=i+1;
U1=str2double(answer{i});i=i+1;
HRUh=str2double(answer{i});i=i+1;
q=str2double(answer{i});i=i+1;
U1m=str2double(answer{i});i=i+1;
Uc1 = U1m*(h^2/(h^2-1));
Ucn = 0.9091*(Uc1+(HRUh*U1*q));
Qcn1 = (3*Ucn^2*Ih)/(HRUh*q*h*U1);
Qcn2 = (3*Ucn^2*Ih)/(sqrt(h)*sqrt(Ucn^2-Uc1^2));
Qcn3 = (3*Ucn^2*Ih)/sqrt(1.69*Ucn^2-Uc1^2);
Qcn4 = max([Qcn1, Qcn2, Qcn3]);
uiwait(msgbox(['Qcn1=' num2str(Qcn1);'Qcn2=' num2str(Qcn2);'Qcn3=' num2str(Qcn3)],'Title','model'));
uiwait(msgbox(['Qcn=' num2str(Qcn4)],'电容器容量','model'));
C = Qcn4/(300*3.14159*Ucn^2);
uiwait(msgbox(['C=' num2str(C)],'电容器参数值','modal'));
w(1)=h;
w(2)=Ih;
w(3)=C;
L = Qcn4/(300*3.14159*h^2*Ucn^2);
w(4)=L;
uiwait(msgbox(['L=' num2str(L)],'电感器参数值','modal'));
Rfh = 1/(h*314.15926*C*q);
w(5)=Rfh;
uiwait(msgbox(['Rfh=' num2str(Rfh)],'滤波器电阻值','modal'));
w1(k,:)=w;
Xc1=3*Ucn^2/Qcn4;
Q1h=3*h^2*U1m^2/((h^2-1)*Xc1);
w2=zeros(1,N);
w2(N)=Q1h;
end
h0=input('请输入截止频率h0=');
if h0>=(h+1)
Q1=0;
for i=1:N
Q1=Q1+w2(i);
end
Q1
if H>=h0%----------高通滤波器参数选择
Ih1=input('请输入h0次以上谐波电流允许值');
U1=input('请输入母线电压值');
Qa=input('请输入工频条件下总的无功补偿');
hm=input('请输入要滤的主要谐波次数');
HRUh=input('请输入h次谐波电压含有率');
fu=@(m)sqrt(m+sqrt(1+2*m)./(m*(1+2*m-m^2)))-hm/h;
m=fzero(fu,0.5);
Xc1=3*U1^2/Qa;
R111=Xc1./h;%高通滤波器电容支路的电阻
Xl1=m*Xc1./h^2;%高通滤波器电容
w1(N+1,1)=h0;
w1(N+1,2)=Ih1;
w1(N+1,3)=1/(2*pi*50*Xc1);
w1(N+1,4)=Xl1/(2*pi*50);
w1(N+1,5)=R111;
else
fprintf('没有高通滤波器');
end
else
fprintf('输入错误');
end
t = uitable;
set(t,'Data',w1)
cnames = {'h','Ih','C','L','Rfh'};
t = uitable('Data',w1,'ColumnName',cnames);