Matlab数据处理(3)

fclose(fidin);   %关闭
fclose(fidtmp);  %关闭
[a,b,c,d,e,t,h,i,j] = textread(tmpfile,'%f %f %f %d %d %d [%d %d] d%d',a1,'headerlines',6);
A = [a,b,c,d,e,t,h,i,j];
%delete(tmpfile);


% index = find((a>0|a<0)&(c>0|c<0)&(b>0|b<0));
% X_3d = a(index);
% Z_3d = c(index);
% Y_3d = b(index);
% pipei = length(Z_3d)/length(c) 

X_3d = a;
Z_3d = c;
Y_3d = b;
H_1 = h;
I_1 = i;

Y_3d = -Y_3d;

%对深度及左右上下范围的截取是必须的,范围由测量目标远近情况调整
%因为很远的地方的一个匹配点,即使是误匹配点,也会使整个图像分布太广
%无法看出大部分匹配点的效果
index4 = find(Y_3d<0.32&Y_3d>0);
X_3d = X_3d(index4);
Z_3d = Z_3d(index4);
Y_3d = Y_3d(index4);

H_1 = H_1(index4);
I_1 = I_1(index4);

index5 = find(X_3d<0.5&X_3d>-0.5);
X_3d = X_3d(index5);
Z_3d = Z_3d(index5);
Y_3d = Y_3d(index5);

H_1 = H_1(index5);
I_1 = I_1(index5);


%匹配率计算
pipei1 = (max(H_1) - min(H_1)) * (max(I_1) - min(I_1));
index6 = find((X_3d>0|X_3d<0)&(Z_3d>0|Z_3d<0)&(Y_3d>0|Y_3d<0));
pipei2 = length(index6);
pipei = pipei2/pipei1 


index3 = find(Z_3d<1.2&Z_3d>0);    
X_3d = X_3d(index3);
Z_3d = Z_3d(index3);
Y_3d = Y_3d(index3);


%以1cm对深度信息进行分层统计
bili(100) = 0;
pingjun(100) = 0;
Z_1 = 0.4;
for i = 1:1:100
    index_i1 = find(Z_3d>=Z_1 & Z_3d<(Z_1 + 0.01));
    num_1 = length(index_i1);
    bili(i) = num_1/length(Z_3d);
    Z_jq1 = Z_3d(index_i1);
    pingjun(i) = mean(Z_jq1);
    Z_1 = Z_1 + 0.01;
end
plot(pingjun,bili*100);



%*********计算平均高度***************
Z_Canopy = mean(Z_3d)

% %画出冠层三维及二维平面图
% figure
% plot3(X_3d,Y_3d,Z_3d,'.','MarkerSize',10);
% figure
% plot(X_3d,Y_3d,'.','MarkerSize',5);
%

你可能感兴趣的:(matlab)