apf,stattcom,inverter

by

 

power electronic simulation

LFpgmnew.m
clc;
clear all;
% load lfdata.m
% XY=lfdata
XY=[415.92      6889560     82367
472.123     6852000     90245
509.671     7035700     95589
551.058     7190900     102344
585.173     7348700     114068
618.585     7491840     123099
648.794     7672000     135952
680.5       7837300     145613
745.896     7975260     160196
809.476     8174900     175419
869.648     8339290     190357
900.851     8439310     207645
943.144     8834730     220674
991.416     9004530     238569
1054.05     9185700     259629
1133.069	9342280     277029
1218.842	9451210     280146
1343.647	9623780     296749
1405.327	9796730     309734
1447.085	9975150     312841
1517.704	10140038	316600
1585.251	10299911	322459
1656.63     10458452	339598
1779.113	10497001	360937
1941.621	10650706	386134
2153.128	10802643	415299
2401.605	10953519	439006
2676.584	11298661	487805
2867.872	11479959	517200
3015.129	11660792	543200
3290.546	11700140	568000];

X=XY(1:31,1:2);%input
Y=XY(1:31,3);%output
X1=X(1:20,1:2);%testing
Y1=XY(1:20,3)
X2=X(21:30,1:2);%training 
Y2=XY(21:30,3)
        minX=min(X);
        maxX=max(X);
        for i=1:size(Y,2)
            minY(i)=min(Y(:,i));
            maxY(i)=max(Y(:,i));
        end
        for i=1:size(X1,1)
             for j=1:size(X1,2)
                 X1n(i,j)=(X1(i,j)-minX(j))/(maxX(j)-minX(j));
            end
        end
        for i=1:size(X2,1)
             for j=1:size(X2,2)
                 X2n(i,j)=(X2(i,j)-minX(j))/(maxX(j)-minX(j));
             end
        end
        for i=1:size(Y1,1)
             for j=1:size(Y1,2)
                 Y1n(i,j)=(Y1(i,j)-minY(j))/(maxY(j)-minY(j));
             end
        end
         
        for i=1:size(Y2,1)
             for j=1:size(Y2,2)
                 Y2n(i,j)=(Y2(i,j)-minY(j))/(maxY(j)-minY(j));
             end
        end
         
         for k=4
        t=cputime;
        MseTe=1;

% %----------Define network structure and initialize weight -----   
    %PR=[min(X1);max(X1)]';
    PR=minmax(X1);
nhid=5;
%nhid2=20;
nout=1;
net=newff(PR,[nhid, nout],{'logsig'  'purelin'}, 'trainscg', 'learngdm', 'mse');
rand('seed',0);
net.layers{1}.initFcn='initwb';
net.inputWeights{1,1}.initFcn='rands';
net.biases{1,1}.initFcn='rands';
net.biases{2,1}.initFcn='rands';
net=init(net);
net.trainParam.epochs=2000;
net.trainParam.goal=0.0001;
[net TR]=train(net,X1n',Y1n');
k
MseTr=TR.perf(size(TR.perf,2))
Time=cputime-t
W1=net.IW{1,1};
b1=net.b{1,1};
W2=net.LW{2};
b2=net.b{2};
t2=cputime;
[y]=sim(net,X2n');
E=Y2n'-y;
Tetime(k-1)=cputime-t2
MseTe=mse(E)
n=size(y,1);
m=size(y,2);
y;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
y=y';
Y2n;
for i=1:size(y,1)
    for j=1:size(y,2)
    ydn(i,j)=y(i,j)*(maxY(j)-minY(j))+minY(j);
end
end
%  ydn;
%  comp=[ydn Y2]
%  Y2;
%  diff=abs(ydn-Y2); 
%  cc=0;
%  error=diff;
%  maxerr=max(diff);
%  minerr=min(diff);
%  MseTe1(k-1)=MseTe
% Time1(k-1)=Time; 
         end

Contact us