Matlab 高脚杯模型切片



有兴趣的可以下载数据,跑程序试一下。也可以单独看看代码,看下实现过程。

  • 主函数
% xls_data=xlsread('data_more.xls');
% x=xls_data(1:3:end);
% y=xls_data(2:3:end+1);
% data=[x,y];
% save('data.mat','data');
clc,clear
load data.mat
x=data(:,2);
y=data(:,1);
yy=smooth(y);
figure
plot(yy,x,'.r');
axis equal
grid on
title('orig data');
%%  拟合
% xx=[min(x):0.1:max(x)]';
% fitsize=4;%拟合次数自己定义
% p=polyfit(x,y,fitsize);
% f=polyval(p,xx);
% figure
% plot(f,xx,'linewidth',2);
% axis equal
% grid on
% title('fit data')
%%
figure
[X,Y,Z] = cylinder(yy(end:-1:1));
[m,n]=size(X);
color=ones(m,n);
h=surf(X,Y,Z);
alpha(0.8)%设定透明度
CM=[1,0,1];
CM=repmat(CM,32,1);
colormap(CM);
lighting gouraud;camlight;shading interp
title('the model')
%%
% figure
% pcolor(X,Y,Z);shading interp%伪彩色图
% figure
% contourf(X,Y,Z) %等高线图
% view(3)
% figure,surf(X,Y,Z)%三维曲面

%%   曲线个数为20  slice图
figure
plot_hor(X,Y,Z,1,10,518,'m');
grid on
plot_hor(X,Y,Z,100,5,400,'m');
title('slice')
%%   骨架图  virtical and horizontal
figure
plot3(X,Y,Z,'linewidth',2,'color','b')
hold on
plot_hor(X,Y,Z,1,5,518,'b');
grid on
title('framework');

  • 被调用函数,用于绘制高脚杯骨架
function plot_hor(x,y,z,First1,Step1,End1,color)

for i=First1:Step1:End1
x_hor=x(i,1:21);y_hor=y(i,1:21);z_hor=z(i,1:21);
plot3(x_hor,y_hor,z_hor,'linewidth',2,'color',color);
hold on
end

end
  • 大致结果如下:

这里写图片描述
这里写图片描述

有兴趣的可以下载数据,跑程序试一下。也可以单独看看代码,看下实现过程。

  • 主函数
% xls_data=xlsread('data_more.xls');
% x=xls_data(1:3:end);
% y=xls_data(2:3:end+1);
% data=[x,y];
% save('data.mat','data');
clc,clear
load data.mat
x=data(:,2);
y=data(:,1);
yy=smooth(y);
figure
plot(yy,x,'.r');
axis equal
grid on
title('orig data');
%%  拟合
% xx=[min(x):0.1:max(x)]';
% fitsize=4;%拟合次数自己定义
% p=polyfit(x,y,fitsize);
% f=polyval(p,xx);
% figure
% plot(f,xx,'linewidth',2);
% axis equal
% grid on
% title('fit data')
%%
figure
[X,Y,Z] = cylinder(yy(end:-1:1));
[m,n]=size(X);
color=ones(m,n);
h=surf(X,Y,Z);
alpha(0.8)%设定透明度
CM=[1,0,1];
CM=repmat(CM,32,1);
colormap(CM);
lighting gouraud;camlight;shading interp
title('the model')
%%
% figure
% pcolor(X,Y,Z);shading interp%伪彩色图
% figure
% contourf(X,Y,Z) %等高线图
% view(3)
% figure,surf(X,Y,Z)%三维曲面

%%   曲线个数为20  slice图
figure
plot_hor(X,Y,Z,1,10,518,'m');
grid on
plot_hor(X,Y,Z,100,5,400,'m');
title('slice')
%%   骨架图  virtical and horizontal
figure
plot3(X,Y,Z,'linewidth',2,'color','b')
hold on
plot_hor(X,Y,Z,1,5,518,'b');
grid on
title('framework');

  • 被调用函数,用于绘制高脚杯骨架
function plot_hor(x,y,z,First1,Step1,End1,color)

for i=First1:Step1:End1
x_hor=x(i,1:21);y_hor=y(i,1:21);z_hor=z(i,1:21);
plot3(x_hor,y_hor,z_hor,'linewidth',2,'color',color);
hold on
end

end
  • 大致结果如下:

这里写图片描述
这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值