stateestimateionyalmip-lu9-.../GetMeasure.m

46 lines
1.6 KiB
Mathematica
Raw Normal View History

function [ mVolt,PD0,QD0,mLoadCurrent ] = GetMeasure( sigma,rVolt,rPD,rQD,rLoadCurrent )
%GETMEASURE Summary of this function goes here
% Detailed explanation goes here
mVolt=(1+normrnd(0,sigma,length(rVolt),1)).*rVolt;
% t1=find(mVolt>(1+1*sigma)*rVolt);
% t2=find(mVolt<(1-1*sigma)*rVolt);
% while any(t1) || any(t2)
% mVolt(t1)=(1+normrnd(0,sigma,length(t1),1)).*rVolt(t1);
% mVolt(t2)=(1+normrnd(0,sigma,length(t2),1)).*rVolt(t2);
% t1=find(mVolt>(1+1*sigma)*rVolt);
% t2=find(mVolt<(1-1*sigma)*rVolt);
% end
PD0=(1+normrnd(0,sigma,length(rPD),1)).*rPD;
% t1=find(PD0>(1+1*sigma)*rPD);
% t2=find(PD0<(1-1*sigma)*rPD);
%
% while any(t1)||any(t2)
% PD0(t1)=(1+normrnd(0,sigma,length(t1),1)).*rPD(t1);
% PD0(t2)=(1+normrnd(0,sigma,length(t2),1)).*rPD(t2);
% t1=find(PD0>(1+1*sigma)*rPD);
% t2=find(PD0<(1-1*sigma)*rPD);
% end
QD0=(1+normrnd(0,sigma,length(rQD),1)).*rQD;
% t1=find(QD0>(1+1*sigma)*rQD);
% t2=find(QD0<(1-1*sigma)*rQD);
% while any(t1)||any(t2)
% QD0(t1)=(1+normrnd(0,sigma,length(t1),1)).*rQD(t1);
% QD0(t2)=(1+normrnd(0,sigma,length(t2),1)).*rQD(t2);
% t1=find(QD0>(1+1*sigma)*rQD);
% t2=find(QD0<(1-1*sigma)*rQD);
% end
mLoadCurrent=(1+normrnd(0,sigma,length(rLoadCurrent),1)).*rLoadCurrent;
t1=find(mLoadCurrent>(1+1*sigma)*rLoadCurrent);
t2=find(mLoadCurrent<(1-1*sigma)*rLoadCurrent);
while any(t1)||any(t2)
mLoadCurrent(t1)=(1+normrnd(0,sigma,length(t1),1)).*rLoadCurrent(t1);
mLoadCurrent(t2)=(1+normrnd(0,sigma,length(t2),1)).*rLoadCurrent(t2);
t1=find(mLoadCurrent>(1+1*sigma)*rLoadCurrent);
t2=find(mLoadCurrent<(1-1*sigma)*rLoadCurrent);
end
end