## 如何使用matlab绘制简单的正方形连续目标(离散点)

如何使用matlab绘制简单的正方形连续目标(离散点)

%利用linspace绘制对应长宽
%x_dim_parameter参数为取值范围
%points_num为取值点数
%为绘制成连续目标需利用meshgrid函数将正方形填满
%此时形成的是二维矩阵,需要利用reshape转为一维,
%x_dimension对应点云的x坐标,其大小为points_num * points_num2 * 2
%y_dimension对应点云的y坐标,其大小为points_num * points_num2 * 2
%z_dimension对应点云的y坐标,其大小为points_num * points_num2 * 2
%Ptar(:,4)对应点云的强度值,此处均设为1,
%Ptar为最终点云,其中Ptar(:,1)为x_dimension,其中Ptar(:,2)为y_dimension
%其中Ptar(:,3)为z_dimension,Ptar(:,4)对应点云的强度值。
x_dim_parameter2 = 0.005;
x_dim_parameter1 = -0.005;
points_num = 10;
x_dimension_mid_1 = linspace(x_dim_parameter1,x_dim_parameter2,points_num);
y_dimension_mid_1 = linspace(x_dim_parameter1,x_dim_parameter2,points_num);
[x_dimension_1,y_dimension_1] = meshgrid(x_dimension_mid_1,y_dimension_mid_1);
z_dimension_1 = 0.5*ones(points_num);
intensity_1 = ones(points_num);

x_dim2_parameter_2 = 0.025;
x_dim2_parameter_1 = -0.025;
points_num2 = 10;
x_dimension_mid_2 = linspace(x_dim2_parameter_1,x_dim2_parameter_2,points_num2);
y_dimension_mid_2 = linspace(x_dim2_parameter_1,x_dim2_parameter_2,points_num2);
[x_dimension_2,y_dimension_2] = meshgrid(x_dimension_mid_2,y_dimension_mid_2);
z_dimension_2 = 0.5*ones(points_num2);
intensity_2 = ones(points_num2);

x_dimension = cat(2,x_dimension_1,x_dimension_2);
z_dimension = cat(2,z_dimension_1,z_dimension_2);
y_dimension = cat(2,y_dimension_1,y_dimension_2);
intensity = cat(2,intensity_1,intensity_2);

Ptar(:,1) = reshape(x_dimension,[],1);
Ptar(:,2) = reshape(y_dimension,[],1);
Ptar(:,3) = reshape(z_dimension,[],1);
Ptar(:,4) = reshape(intensity,[],1);

你可能感兴趣的:(matlab,matlab)