how does cdfplot works?
이전 댓글 표시
can someone tell me how cdfplot works....? i know the matlab help about this function but i dont understand it...the answer in my code is upside down but it should be like this picture...
clc;
clear;
C=[250;200;150;150;100];
q=[0.15;0.15;0.1;0.1;0];
y=[660;660;770;880];
f=[10;15;20;25;30;50];
Aeq=ones(1,6);
LB=zeros(6,1);
prob=[0.25;0.25;0.25;0.25];
%% Monte Carlo
iteration=3000;% Number of iterations
deterministic_index=zeros(iteration,1);
margin=zeros(iteration,1);
for t=1:iteration
%generation program
for i=1:length(C)
if rand<=q(i)
outage_capacity(i)=C(i);
UB1(i)=0;
else
UB1(i)=C(i);
outage_capacity(i)=0;
end
end
%% Load random samples
sum_prob(1)=prob(1);
for i=2:length(prob)
sum_prob(i)=sum_prob(i-1)+prob(i);
end
flag=find(rand<=sum_prob);
load=y(min(flag));
%% Margin random variable
margin(t) = sum(C) - sum(outage_capacity) - load;
if margin(t)<0
deterministic_index(t)=1;
end
beq=load;
UB=[UB1,beq] ;
[X,faval,exitflag]=linprog(f,[],[],Aeq,beq,LB,UB);
X1(:,t)=X;
end
C1 = X1(1,:);
C2 = X1(2,:);
C3 = X1(3,:);
C4 = X1(4,:);
C5 = X1(5,:);
Plsh = X1(6,:);
% Plsh=Plsh(end:-1:1);
ExpectationC1 = mean(C1);
ExpectationC2 = mean(C2);
ExpectationC3 = mean(C3);
ExpectationC4 = mean(C4);
ExpectationC5 = mean(C5);
ExpectationPlsh = mean(Plsh);
standard_deviationC1 = std(C1);
standard_deviationC2 = std(C2);
standard_deviationC3 = std(C3);
standard_deviationC4 = std(C4);
standard_deviationC5 = std(C5);
standard_deviationPlsh = std(Plsh);
LOLP = mean(deterministic_index);
LOLE = 8760*LOLP;
EENS = mean(mean(margin .* deterministic_index));
disp(['LOLP=',num2str(LOLP)]);
disp(['LOLE=',num2str(LOLE)]);
disp(['EENS=',num2str(EENS)]);
disp(['ExpectationC1=',num2str(ExpectationC1)]);
disp(['ExpectationC2=',num2str(ExpectationC2)]);
disp(['ExpectationC3=',num2str(ExpectationC3)]);
disp(['ExpectationC4=',num2str(ExpectationC4)]);
disp(['ExpectationC5=',num2str(ExpectationC5)]);
disp(['ExpectationPlsh=',num2str(ExpectationPlsh)]);
disp(['standard_deviationC1=',num2str(standard_deviationC1)]);
disp(['standard_deviationC2=',num2str(standard_deviationC2)]);
disp(['standard_deviationC3=',num2str(standard_deviationC3)]);
disp(['standard_deviationC4=',num2str(standard_deviationC4)]);
disp(['standard_deviationC5=',num2str(standard_deviationC5)]);
disp(['standard_deviationPlsh=',num2str(standard_deviationPlsh)]);
disp(['Exitflag=',num2str(exitflag)]);
%% Probability Density Function
figure(1);
subplot(3,2,1); hist(C1); title('Probability Density Function(Unit1)');
subplot(3,2,2); hist(C2); title('Probability Density Function(Unit2)');
subplot(3,2,3); hist(C3); title('Probability Density Function(Unit3)');
subplot(3,2,4); hist(C4); title('Probability Density Function(Unit4)');
subplot(3,2,5); hist(C5); title('Probability Density Function(Unit5)');
figure(2);
hist(Plsh); title('Probability Density Function(Plsh)');
%%Cumulative distribution function
figure(3);
subplot(5,1,1); cdfplot(C1); title('Cumulative distribution function(Unit1)');
subplot(5,1,2); cdfplot(C2); title('Cumulative distribution function(Unit2)');
subplot(5,1,3); cdfplot(C3); title('Cumulative distribution function(Unit3)');
subplot(5,1,4); cdfplot(C4); title('Cumulative distribution function(Unit4)');
subplot(5,1,5); cdfplot(C5); title('Cumulative distribution function(Unit5)');
figure(4);
cdfplot(Plsh);
댓글 수: 7
Torsten
2022년 12월 10일
I understand cdfplot, but I don't understand your picture. Funny, isn't it ?
arian hoseini
2022년 12월 10일
arian hoseini
2022년 12월 10일
I'm not sure, though, if this is what you want.
You should explain in detail how you want to transform the original CDF curve.
Maybe the following code will do what you want:
x = rand(1000,1);
h = cdfplot(x);
h.XData(1:end-1) = h.XData(end-1)-h.XData(1:end-1);
h.YData = fliplr(h.YData);
arian hoseini
2022년 12월 10일
As you see from my answer, you get access to the x and y plot data by
h = cdfplot(x)
x = h.XData
y = h.YData
Now you can rearrange the data according to your needs.
I mention this because I'm still not sure whether the suggested rearrangement is correct in your case. You will have to check it carefully.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Spline Postprocessing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

