面朝大海,春暖华开

focus on scientific computue, 3dgis, spatial database
专注于科学计算、GIS空间分析

 

测树学weibull拟合matlab程序,难者不会,会者不难

function [N,k,x,dbh,n_fit parmhat, parmci]=WblDbh(n,a,W)
% 根据整化的径阶,进行weibull拟合
% n : 径阶株数
% dbh : 各株的胸径大小
% N 株数
% k 径阶数
% x 径阶胸径
% n_fit 各径阶拟合值
% parmhat, parmci weibull拟合结果

%W = 1; %径阶距
%a = 6; %起测胸径
dbh = [];
for i = 1:length(n)
  
    %tmp = GetDbhFrom(i,a,W)*ones(n(i),1);
    tmp = GetDbhFrom(i,0,W)*ones(n(i),1);
    dbh = [dbh;tmp];
end
N = length(dbh);
k = length(n);
%dbh = dbh - a;  % 起测胸径平移
[parmhat parmci]= wblfit(dbh);
A=parmhat(1)
B=parmhat(2)
%figure();
f=k-3-1; %自由度
%x = W/2: W : k*W; %径阶中值
x = GetDbhFrom([1:k],0,W);
%x = GetDbhFrom([1:k],a,W);
%各径阶理论株数;
n_fit=round( N*W*B/A*power(x/A,B-1).*exp(-1*power(x/A,B)));
%n_fit = round( N*W * wblpdf(x, A,B));
figure;
plot(x +a,n,'*',x+a ,n_fit,'-o');
%chi-test
end

 

function dbh = GetDbhFrom(i,a,W)
%W = 1; %径阶距
%a = 6; %起测胸径
%dbh 第i径阶的胸径

dbh = W/2 + a + (i-1)*W;
end

 

posted on 2010-01-17 20:41  风过 无痕  阅读(2127)  评论(0编辑  收藏  举报

导航

向日葵支付宝收钱码