本文介绍了如何在Matlab中使用电子表格制作3d平面图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

pointA=[9.62579 15.7309 3.3291];
pointB=[13.546  25.6869 3.3291];
pointC=[23.502  21.7667 -3.3291];
pointD=[19.5818 11.8107 -3.3291];

points=[pointA' pointB' pointC' pointD'];
fill3(points(1,:),points(2,:),points(3,:),'r')
grid on
alpha(0.3)

此代码将显示一个已填充的平面(无法添加图像,并且不能T.T)

This code will show a filled plane(Cant add images yet T.T)

现在这是我的问题.在电子表格上,我有数千个点的x,y,z坐标.四个连续点形成一个如图所示的平面.如何编写代码,使每四个连续点构成一个填充平面.基本上,如果我有400个点,我希望代码绘制100个平面.

Now here is my problem. On a spreadsheet, I have x,y,z coordinates of thousands of points. The 4 consecutive points form a plane like the one shown. How do I make a code such that for every 4 consecutive points, it makes a filled plane.Basically, if I have 400 points, I want the code to plot 100 planes.

推荐答案

假设您的数据是矩阵,则m =(400,3)

Assuming your data are a matrix, m = (400,3)

m = rand(400,3); for i = 1:length(m); m2 = m'; % Transpose end

m = rand(400,3); for i = 1:length(m); m2 = m'; % Transpose end

创建一个3D矩阵,其中"j"代表每组点:

Create a 3-D matrix in which 'j' represents each set of points:

m3=[];

%不是循环浏览每四个点的最优雅的方法,但是它有效!

%Not the most elegant way to cycle through every four points but it works!

z = 0:(length(m2)/4); z1 = (z*4)+1; z1 = z1(:,1:length(z)-1); 
    for j = 1:length(z1);
        m3(:,:,j) = m2(:,z1(j):(z1(j)+3));
    end

'j'现在的总长度= 100-代表数量平面;

'j' now has a total length = 100 - representing the amount planes;

fill3(m3(1,:,1),m3(2,:,1),m3(3,:,1),'r'); 

%在飞机上循环-为每个飞机绘制一个新的数字;

% Cycle through planes- make a new figure for each plane;

for j = 1:length(z1);
    fill3(m3(1,:,j),m3(2,:,j),m3(3,:,j),'r'); 
end

这篇关于如何在Matlab中使用电子表格制作3d平面图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 16:27