matlab绘制密度的曲线图,急!如何运⽤matlab得出概率密度
函数(pdf)的曲线图?...
我有⼀组降⽔量数据,14年,想对其画出概率密度函数的曲线图。已经得出了直⽅图,请问,怎样从直⽅图得出概率密度函数的曲线图(⼜称pdf图)?本⼈刚学习matlab,盼⼤侠出⼿相助。
这是去年使⽤过的PDF程序,什么地⽅才是关键呢?谢谢各位⼤虾了
clear all;
threshold=10;
% tbmax=1000; % threshold=2
% tbmax=1000; % threshold=3
% tbmax=1000; % threshold=4
% tbmax=1000; % threshold=5
% tbmax=1000; % threshold=6
% tbmax=1000; % threshold=7
% tbmax=1000; % threshold=8
% tbmax=1000; % threshold=9
% tbmax=1000; % threshold=10
% tbmax=1000; % threshold=11
% tbmax=1000; % threshold=12
% tbmax=1000; % threshold=13
% tbmax=1500; % threshold=14
% tbmax=2000; % threshold=15
% tbmax=3000; % threshold=16
% tbmax=3000; % threshold=17
% tbmax=10000; % threshold=18
% tbmax=10000; % threshold=19
% tbmax=20000; % threshold=20
% tbmax=40000; % threshold=21
% tbmax=40000; % threshold=22
% tb(1)=44131;%,
% tb(2)=44136;%,
% tb(3)=44166;%,
% tb(4)=45106;%,
% tb(5)=45212;%,
% tb(7)=45401;%,
% tb(8)=46106;%,
% tb(9)=46211;%,
Y = pdf('name',X,A1,A2,A3) fr1=fopen('./wind.dat','r'); wind=fscanf(fr1,'%f',[1 Inf]); fclose(fr1);
fr2=fopen('./ke.dat','r');
ke=fscanf(fr2,'%f',[1 Inf]); fclose(fr2);
fn='./tke .dat';
fn(6)='0'+fix(threshold/10); fn(7)='0'+mod(threshold,10); fr3=fopen(fn,'r');
tke=fscanf(fr3,'%f',[1 Inf]); fclose(fr3);
n=size(tke,2)
for ii=1:1:n
if wind(ii)<0
ke(ii)=-ke(ii);
end
end
% jjtw=0;
% jjtb=0;
% ictw=0;
% for ii=1:1:n
% if tke(ii)>0 & ictw==0
% jjtw=jjtw+1;
% ictw=1;
% stw=ii;
% else tke(ii)>0 & ictw==1 % etw=ii;
% end
ii=0;
% for ii=1:1:n
for iii=1:1:n-8760
% if mod(ii,5000)==0
% ii
% end
ii=ii+1;
if ii
if tke(ii)>0
jjtw=jjtw+1;
stw(jjtw)=ii;
while tke(ii)>0 | tke(ii+1)>0
ii=ii+1;
etw(jjtw)=ii-1;
end
tw(jjtw)=etw(jjtw)-stw(jjtw)+1;
meantke(jjtw)=mean(tke(stw(jjtw):etw(jjtw)))-threshold^2; end
end
end
for ii=1:1:jjtw-1
tb(ii)=stw(ii+1)-etw(ii);
end
% ------ interval, tw, is more than threshhold wi ------ %
wi=1;
jjitw=0;
for ii=1:1:jjtw-1
if tw(ii)>=wi
jjitw=jjitw+1;
itw(jjitw)=tw(ii);
iitb(jjitw)=ii;
imeantke(jjitw)=mean(tke(stw(ii):etw(ii)))-threshold^2;
for ii=1:1:jjitw-1
itb(ii)=0;
for jj=iitb(ii):1:iitb(ii+1)-1
itb(ii)=itb(ii)+tb(jj)+tw(jj+1);
end
end
% ------ interval, tw, is more than threshhold wi ------ % stw;
etw;
max(tw)
max(tb)
max(meantke)
matlab直方图
% x_tw=[0:1:max(tw)];
% x_tb=[0:max(tb)/20:max(tb)];
% x_meantke=[0:max(meantke)/20:max(meantke)];
x_tw=[1/2:1:24+1];
x_tb=[tbmax/24/2:tbmax/24:tbmax+tbmax/24];
x_meantke=[200/24/2:200/24:200+200/24];
figure(10);
clf;
axes('Position',[0.1 0.1 0.8 0.36]);
plot(wind,'k-');
axes('Position',[0.1 0.6 0.8 0.36]);
plot(ke,'k-');
figure(11);
clf;
axes('Position',[0.1 0.1 0.8 0.36]);
plot(tke,'k-');
% axis([0 5000 0 800]);
figure(12);
clf;
axes('Position',[0.1 0.07 0.8 0.24]);
h1 = findobj(gca,'Type','patch');
set(h1,'FaceColor','k','EdgeColor','w') axis([1 24 0 jjtw*0.25]);
axes('Position',[0.1 0.4 0.8 0.24]); hist(tb,x_tb);
h1 = findobj(gca,'Type','patch');
set(h1,'FaceColor','k','EdgeColor','w') axis([0 tbmax 0 jjtw*0.5]);
axes('Position',[0.1 0.73 0.8 0.24]); hist(meantke,x_meantke);
h1 = findobj(gca,'Type','patch');
set(h1,'FaceColor','k','EdgeColor','w') axis([0 200 0 jjtw*0.25]);
fign='./figures/tr_tb_mke ';
fign(20)='0'+fix(threshold/10);
fign(21)='0'+mod(threshold,10); print('-djpeg',fign);
print('-deps2',fign);
figure(13);
clf;
axes('Position',[0.1 0.07 0.8 0.24]); hist(itw,x_tw);
h1 = findobj(gca,'Type','patch');
set(h1,'FaceColor','k','EdgeColor','w') axis([1 24 0 jjitw*0.25]);
axes('Position',[0.1 0.4 0.8 0.24]); hist(itb,x_tb);
h1 = findobj(gca,'Type','patch');
set(h1,'FaceColor','k','EdgeColor','w') axis([0 tbmax 0 jjitw*0.5]);
axes('Position',[0.1 0.73 0.8 0.24]); hist(imeantke,x_meantke);
h1 = findobj(gca,'Type','patch');
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论