MATLABEmail qkdong@mail.xidian.edu.cnhttp://web.xidian.edu.cn/qkdong/
1. Matlab2. 3. 4.
Matlab1xmean(x) std(x)median(x) var(x)skewness(x) kurtosis(x)2Adata [N,X]=hist(data,k) [min(data),max(data)]k(10)dataNXBdata hist(data,k)
Matlab3A[muhat,sigmahat,muci,sigmaci]=normfit(x,alpha)alphaxalpha5%muhatsigmahatmucisigmaciB[muhat,muci]=expfit(x,alpha)[lambdahat, lambdaci]=poissfit(x,alpha)[phat, pci]=weibfit(x,alpha)
Matlab4Az [h,sig,ci]=ztest(x,m,sigma,alpha,tail)xsigmaalphatailtail=0xmtail=1xmtail=-1xmtail0 alpha5%hh=1 h=0sigci1- alpha
MatlabBt [h,sig,ci]=ttest(x,m,alpha,tail)Ct [h,sig,ci]=ttest2(x,y,alpha,tail)
Matlab5MatlabA h=normplot(x)xBh=weibplot(x)xWeibullWeibull
1 box30AB A8292776270368010074646356727868657270589279,926556857361714289 B5767645477657158596967846395814649, 60, 646674555863656876724872 >> clearx=[82,92,77,62,70,36,80,100,74,64,63,56,72,78,68,65,72,70,58,92,79,92,65,56,85,73,61,71,42,89;57,67,64,54,77,65,71,58,59,69,67,84,63,95,81,46,49,60,64,66,74,55,58,63,65,68,76,72,48,72]; boxplot(x')2.
A()B()AB(A25BAB25)A70()B65()A()B()
2 6.3 5001650016 602516
>> %1x=[];%for byk=1:500 %500500 xx=normrnd(60,5,16,1);%N(60,25)16 x=[x,xx]; %xmatlabworkspaceend %21~500xmean=mean(x);%500 %3500k=ceil(1.87*(length(x)-1)^(2/5));%h=histfit(xmean,k);%set(h(1),'FaceColor','c','EdgeColor','w')% %4500M=mean(xmean) %1~500V=var(xmean)%1~500
M = 59.9879V = 1.4129
M = 60.0117V = 1.3900
M = 59.9749V = 1.5158
M = 59.9929V = 1.5757
M = 59.8809V = 1.6855
3 binornd5000>> clear;clf, n=5;p=0.5;m=5000;x=[0:1:n]rand('seed',3)R=binornd(n,p,1,m);% mfor I=1:n+1 % k=[ ]; k=find(R==(I-1));%findR(I-1)k h(I)=length(k)/m;%(I-1)endbar(x,h),axis([-1 6 0 1])%title('\fontsize{18}\fontname{}5000')
>> f=binopdf(x,n,p), bar(x,f), axis([-1 6 0 1]) title('\fontsize{18}\fontname{}B(5,0.5)')
MATLABpdfcdfinvstatrnd MATLAB2 chi2t tF f2 ncx2t nctF ncf
3.
4 2 >> %clear,clfX=linspace(0,20,100);Y1=chi2pdf(X,1);%1Y2=chi2pdf(X,3);%3Y3=chi2pdf(X,6);%6plot(X,Y1,'-g',X,Y2,'-b',X,Y3,'-k')title('\fontsize{18}\fontname{}{\chi}^2')text(0.6,0.6,'\fontsize{12}df:n=1')text(2.6,0.2,'\fontsize{12}df:n=3')text(8.6,0.09,'\fontsize{12}df:n=6')legend('df:n=1','df:n=3','df:n=6')
>> %tclear,clfX=linspace(-4,4,100);Y0=normpdf(X,0,1);%Y1=tpdf(X,45);%45Y2=tpdf(X,4);%4Y3=tpdf(X,2);%2YY0=normpdf(0,0,1);plot(X,Y0,'.b',X,Y1,'-c',X,Y2,'-m',X,Y3,'-k',[0,0],[0,YY0],':r')title('\fontsize{18}\fontname{}t')legend('N(0,1)','df:n=45','df:n=4','df:n=2')5 t
>> %Fclear,clfX=linspace(0,6,100);Y=fpdf(X,10,5);%10,5plot(X,Y)text(1.5,0.55,'\fontsize{14}df:n1=10,n2=5')6 F
>>clear,clfX=linspace(0,6,100);Y11=fpdf(X,100,10);%100,10Y12=fpdf(X,5,10);%5,10Y21=fpdf(X,10,100);%10,100Y22=fpdf(X,10,5);%10,5subplot(2,1,1)plot(X,Y11,X,Y12)legend('df:n1=100,n2=10','df:n1=5,n2=10')title('\fontsize{18}\fontname{}F')subplot(2,1,2)plot(X,Y21,X,Y22)legend('df:n1=10,n2=100','df:n1=10,n2=5')7 F
8 20000N2000ND20mm0.5mm412MPa15.6MPa
PdS
0.99999991
>> N=100000;St=0;P_mean=20000;P_sigma=2000;D_mean=20;D_sigma=0.5;Q_mean=412*10^6;Q_sigma=15.6*10^6;for i=1:N p=P_mean+P_sigma*randn(1); d=D_mean+D_sigma*randn(1); q=Q_mean+Q_sigma*randn(1); s=(4*p)/(pi*d^2); if s
3. 9 100459 362 624 542 509 584 433 748 815 505 612 452 434 982 640 742 565 706 593 680 926 653 164 487 734 608 428 1153 593 844 527 552 513 781 474 388 824 538 862 659 775 859 755 49 697 515 628 954 771 609 402 960 885 610 292 837 473 677 358 638 699 634 555 570 84 416 606 1062 484 120 447 654 564 339 280 246 687 539 790 581 621 724 531 512 577 496 468 499 544 645 764 558 378 765 666 763 217 715 310 851
>> %x1=[459 362 624 542 509 584 433 748 815 505];x2=[612 452 434 982 640 742 565 706 593 680];x3=[926 653 164 487 734 608 428 1153 593 844];x4=[527 552 513 781 474 388 824 538 862 659];x5=[775 859 755 49 697 515 628 954 771 609];x6=[402 960 885 610 292 837 473 677 358 638];x7=[699 634 555 570 84 416 606 1062 484 120];x8=[447 654 564 339 280 246 687 539 790 581];x9=[621 724 531 512 577 496 468 499 544 645];x10=[764 558 378 765 666 763 217 715 310 851];x=[x1 x2 x3 x4 x5 x6 x7 x8 x9 x10];%hist(x,10)[N,X]=hist(x,10)%normplot(x)
N = 3 3 7 14 24 22 14 8 3 2
X = 1.0e+003 *
0.1042 0.2146 0.3250 0.4354 0.5458 0.6562 0.7666 0.8770 0.9874 1.0978
>> %[muhat,sigmahat,muci,sigmaci]=normfit(x)muhat = 594sigmahat = 204.1301muci = 553.4962 634.5038sigmaci = 179.2276 237.1329
594204.130195%[553.4962634.5038]95%[179.2276237.1329]
>> %[h,sig,ci]=ttest(x,594)%594h = 0sig = 1ci = 553.4962 634.5038
h=0594 95%[553.4962634.5038]594sig = 10.05594
45621,3,5,7,100