clear;
clc;
% [myExcelData,Title]=xlsread('BPA.xlsx');
[myExcelData,Title]=xlsread('IEEE9-3.xlsx');
[myExcelData2,Title2]=xlsread('IEEE9-9.xlsx');
% pregetdata=myExcelData(:,13);
% pregetdata2=myExcelData2(:,13);
pregetdata=myExcelData(:,9);
pregetdata2=myExcelData2(:,9);
jj=0;
for ii=1:802
if
(ii==1)|(ii==12)
continue;
end
jj=jj+1;
getdata(jj,1)=pregetdata(ii,1);
getdata2(jj,1)=pregetdata2(ii,1);
end
vc1Constant=1.032;
vc2Constant=1.031;
rij=getdata-vc1Constant;
rij2=getdata2-vc2Constant;
hold on;
% a0=[0.4 0.4 0.4 0.4 2];
% a0=[0.2 0.2 0.4 0.2 1];
% options=optimset('fminsearch');
% options.TolX=0.0001;
% options.Display='off';
% a=fminsearch(@twoexps,a0,options,x,y);
%==========最小二乘逼近==========
a0=[1 1 1 1 1];
a=lsqcurvefit('curvefun1',a0,x,y);
f=curvefun1(a,x);
% plot(x,f,'b');
% legend('实测','拟合');
%==============================
% yset=a(1)*exp(-a(2)*x).*sin(a(3)*x)+a(4)*exp(-a(5)*x);
%
% plot(x,yset,'b');
% fun=jifen(a,x);
result=quad(@(x)jifen(a,x),0,15.98);
disp('result= ');
disp(result);
%==========================作图注释============================
y2=rij2';
% %subplot(2,2,2);
plot(x,y2,'r');
xlabel('时间 t/s')
ylabel('电压幅值 p.u')
hold on;
%
%
%
%
%
% %===========第二次不同传输功率做最小二乘逼近============
b0=[1.2 1 1 1 1];
b=lsqcurvefit('curvefun1',b0,x,y2);
f2=curvefun1(b,x);
plot(x,f2,'b');
legend('实测','拟合');
%========================作图注释=====================
% b0=[1 1 1 1 1];
% options=optimset('fminsearch');
% options.TolX=0.001;
% options.Display='off';
% b=fminsearch(@twoexps,b0,options,x,y2);
% yset2=b(1)*exp(-b(2)*x).*sin(b(3)*x)+b(4)*exp(-b(5)*x);
% plot(x,yset2,'b');
result2=quad(@(x)jifen(b,x),0,15.98);
disp('result2= ');
disp(result2);
%第一次仿真 对应P :122.9MW
%第二次仿真 对应P2: 64.3MW
P=122.9;
P2=126.7;
% result=0.2;
% 求解方程 result*(Li-122.9)=result2*(Li-64.3);
Li=(P2*result2-P*result)/(result2-result);
Cij=result*(Li-P);
disp('Li= ');
disp(Li);
disp('Cij=')
disp(Cij);