代码段禁止出现在毕业设计、商业活动中!仅供交流。
代码段
相关参数已在代码中标注,由于是自己参考论文编写的并且才接触matlab不到一周,因此采用的比较多的循环结构,程序某些地方可能多余(懒得删除),而且程序运行比较慢,大家可以参考自己进行优化。
%% initialization
clear;
close all;
clc;
%% known conditions
n = 500; %Spindle speed of lathe,r/min 主轴转速
Rdt = 1.554; %Radius of arc knife,mm 刀尖圆弧半径
s = 15; %Spindle feed speed,mm/min 主轴进给速度
h = 2/1000; %Depth of cut,mm 加工深度
%% Assumptions
Rw = 0.5;%Workpiece radius,mm 工件半径
Lx = 0.25;%The length of the simulation area,mm 加工长度
Ly = 0.25;%Width of simulation area,mm 加工宽度
Sf = s/n; %Feed per revolution,mm/r 进给速度(注意单位)
mx = Sf/10;
my = Sf/10;
N = ceil(Lx/mx);
M = ceil(Rw/Sf);
% Overall surface roughness
Rt = Rdt - sqrt(Rdt^2-(Sf^2)/4); %总的表面粗糙度
%% Set matrix
AA = [];
k = 0:1:M;
rk = [];
%% Calculate profile height
for i = 0:N
for j = 0:N
%Cartesian coordinates of points
Xij = i*mx-Lx/2;
Yij = j*my-Ly/2;
%Point polar coordinates
r = sqrt(Xij^2+Yij^2);
theta = atan(Yij/Xij);
% jidge theta
if theta < 0
theta = theta +2*pi;
elseif theta >= 2*pi
theta = theta -2*pi;
else
theta = theta;
end
%compute the height of the point
hk = [];
for k = 1:M
if i < N/2
rk = Rw - Sf*(k + theta/(2*pi));
else
rk = Rw - Sf*((k-0.5) + theta/(2*pi));
end
hk1 = Rdt*(1-(sqrt(1-((r-rk)/Rdt)^2)));
hk = [hk,hk1];
end
hklow = min(min(hk));
% Judge height and processing depth
if hklow > h
hklow = h;
end
% save the min height
AA = [AA,hklow];
end
end
%List the coordinate range
Ax = linspace(0,0.25,N+1);
Ay = Ax;
% Into a square
AA = reshape(AA,[N+1,N+1]);
% Drawing
surf(Ay,Ax,AA);
title('Surface microtopography');
xlabel('x-axis');
ylabel('y-axis');
zlabel('z-axis');
效果验证
参考文献
[1]尹自强,李圣怡.振动影响下金刚石车削表面的形貌仿真[J].国防科技大学学报,2003(01):78-83.
[2]尹自强,李圣怡.超精密车削表面三维微观形貌仿真及特征分析[J].航空精密制造技术,2003(04):1-5.
备注
1、编写程序时,任务要求没有加入振动影响,因此在此忽略了振动因素对表面粗糙度的影响。
2、轻喷代码,新手练习的。
3、不得在毕业设计、商业中出现该代码段,优化/更改后的可以。
有问题请留言,会及时回复的。