|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
请教各位大侠我用mesh画的图为什么图可以显示出来但是等图显示出来按钮却看不见了
程序如下
function varargout = yaoyao(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @yaoyao_OpeningFcn, ...
'gui_OutputFcn', @yaoyao_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
function yaoyao_OpeningFcn(hObject, eventdata, handles, varargin)
global A
global z1
global z2
global kc
global kr
global ha_c
global hf_c
global c_c
global c2
handles.output = hObject;
guidata(hObject, handles);
function varargout = yaoyao_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function A_Callback(hObject, eventdata, handles)
function A_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function Z1_Callback(hObject, eventdata, handles)
function Z1_CreateFcn(hObject, eventdata, handles)
t(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function Z2_Callback(hObject, eventdata, handles)
function Z2_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function kc_Callback(hObject, eventdata, handles)
function kc_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function k1_Callback(hObject, eventdata, handles)
function k1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function kr_Callback(hObject, eventdata, handles)
function kr_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function hac_Callback(hObject, eventdata, handles)
function hac_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function hfc_Callback(hObject, eventdata, handles)
function hfc_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function c_Callback(hObject, eventdata, handles)
function c_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function C1_Callback(hObject, eventdata, handles)
function C1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function d1_Callback(hObject, eventdata, handles)
function d1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function zuochimian_Callback(hObject, eventdata, handles)
Hx=findobj('tag','A');
A=str2num(get(Hx,'string'));
Hx=findobj('tag','Z1');
z1=str2num(get(Hx,'string'));
Hx=findobj('tag','Z2');
z2=str2num(get(Hx,'string'));
Hx=findobj('tag','kc');
kc=str2num(get(Hx,'string'));
Hx=findobj('tag','k1');
k1=str2num(get(Hx,'string'));
Hx=findobj('tag','kr');
kR=str2num(get(Hx,'string'));
Hx=findobj('tag','hac');
ha_c=str2num(get(Hx,'string'));
Hx=findobj('tag','hfc');
hf_c=str2num(get(Hx,'string'));
Hx=findobj('tag','c');
c_c=str2num(get(Hx,'string'));
Hx=findobj('tag','C1');
c2=str2num(get(Hx,'string'));
alfa=-0.6*pi/180; %蜗轮螺旋角
i=z1/z2; %传动比
d1=k1*A; %蜗杆喉部分度圆直径
m=(2*A-d1)/z2; %模数
ha=ha_c*m; hf=hf_c*m; c=c_c*m; %齿顶高,齿根高,顶隙
df1=d1-2*(hf+c); %蜗杆喉部齿根圆直径
da1=d1+2*ha; %蜗杆喉部齿顶圆直径
d2=2*A-d1; %蜗轮分度圆直径
da2=d2+2*ha; %蜗轮齿顶圆直径
df2=d2-2*(hf+c); %蜗轮齿跟圆直径
a2=da2/2*cos(alfa);
b2=da2/2*sin(alfa);
Z=ones(size(d))*rf1*sin(t);
%set(findobj('tag','text13'),'Visible',on);
shading interp; colormap(copper)
xlabel('\fontsize{20}\itz\rm_{1}\fontsize{18}/mm')
zlabel('\fontsize{20}\ity\rm_{1}\fontsize{18}/mm')
box off
hold off
for step=-1:3:11 %u - 滚子高度参数
u=step*c; %u - 滚子高度参数
fai2=linspace(-3*2*pi*i,3.08*2*pi*i,500); %fai2 - 蜗轮转角
fai1=fai2/i; %fai1 - 蜗杆转角
e1=sin(-alfa)*(i*b2-c2*cos(fai2))+cos(-alfa)*(c2*sin(fai2)-i*a2);
e2=sin(fai2)*(u*sin(-alfa)+b2)+cos(fai2)*(u*cos(-alfa)-a2)+A;
tan_theta=e2./e1;
theta=-abs(atan(tan_theta));
x0=R*cos(theta);
y0=R*sin(theta);
z0=u*ones(size(fai1));
x1=-x0.*sin(fai1)+y0.*(cos(fai1).*sin(fai2)*cos(-alfa)-cos(fai1).*cos(fai2)*sin(-alfa))-a2.*cos(fai1).*cos(fai2)+b2.*cos(fai1).*sin(fai2)-c2.*sin(fai1)+A.*cos(fai1)+z0.*(cos(fai1).*cos(fai2)*cos(-alfa)+cos(fai1).*sin(fai2)*sin(-alfa));
y1=-x0.*cos(fai1)+y0.*(sin(fai1).*cos(fai2)*sin(-alfa)-sin(fai1).*sin(fai2)*cos(-alfa))+a2.*sin(fai1).*cos(fai2)-b2.*sin(fai1).*sin(fai2)-c2.*cos(fai1)-A.*sin(fai1)-z0.*(sin(fai1).*cos(fai2)*cos(-alfa)+sin(fai1).*sin(fai2)*sin(-alfa));
z1=-y0.*(sin(fai2)*sin(-alfa)+cos(fai2)*cos(-alfa))-a2*sin(fai2)-b2*cos(fai2)+z0.*(sin(fai2)*cos(-alfa)-cos(fai2)*sin(-alfa));
x1=cos(fai1).*cos(fai2).*(A*cos(fai2)+z0*cos(-alfa)-y0*sin(-alfa)-a2)+...
cos(fai1).*sin(fai2).*(b2+y0*cos(-alfa)+z0*sin(-alfa)+A*sin(fai2))-...
sin(fai1).*(c2+x0);
y1=sin(fai1).*cos(fai2).*(a2+y0*sin(-alfa)-z0*cos(-alfa)-A*cos(fai2))-...
sin(fai1).*sin(fai2).*(b2+y0*cos(-alfa)+z0*sin(-alfa)+A*sin(fai2))-...
cos(fai1).*(c2+x0);
z1=sin(fai2).*(A*cos(fai2)+z0*cos(-alfa)-y0*sin(-alfa)-a2)-cos(fai2).*...
(b2+y0*cos(-alfa)+z0*sin(-alfa)+A*sin(fai2));
plot3(z1,y1,x1,'b');
hold on
end
jj=0; %写文件用循环变量
for step_2=linspace(-3,3.5,300) %step控制接触线疏密程度
fai2=step_2*2*pi*i; %fai2 - 蜗轮转角
fai1=fai2/i; %fai1 - 蜗杆转角
jj=jj+1;
theta=-pi*(0:2000)/2000;
B4=sin(-alfa)*sin(theta)*(c2*cos(fai2)-i*b2)+...
(i*a2-c2*sin(fai2))*sin(theta)*cos(-alfa)+...
(A-a2*cos(fai2)+b2*sin(fai2))*cos(theta);
B5=i*sin(theta)-cos(theta)*(cos(fai2)*cos(-alfa)+sin(fai2)*sin(-alfa));
u=B4./B5;
S=(find(u>0&u<15)); %柱面参数u的边界条件
u=u(S);
theta=theta(S); %与u对应的theta
x0=R*cos(theta);
y0=R*sin(theta);
z0=u; %u is a variable
x1=cos(fai1)*cos(fai2)*(A*cos(fai2)+z0*cos(-alfa)-y0*sin(-alfa)-a2)+...
cos(fai1)*sin(fai2)*(b2+y0*cos(-alfa)+z0*sin(-alfa)+A*sin(fai2))-...
sin(fai1)*(c2+x0);
y1=sin(fai1)*cos(fai2)*(a2+y0*sin(-alfa)-z0*cos(-alfa)-A*cos(fai2))-...
sin(fai1)*sin(fai2)*(b2+y0*cos(-alfa)+z0*sin(-alfa)+A*sin(fai2))-...
cos(fai1)*(c2+x0);
z1=sin(fai2)*(A*cos(fai2)+z0*cos(-alfa)-y0*sin(-alfa)-a2)-cos(fai2)*...
(b2+y0*cos(-alfa)+z0*sin(-alfa)+A*sin(fai2));
plot3(z1,y1,x1,'k');
end;
pushbutton5_Callback(hObject, eventdata, handles)
function youchimian_Callback(hObject, eventdata, handles)
Hx=findobj('tag','A');
A=str2num(get(Hx,'string'));
Hx=findobj('tag','Z1');
z1=str2num(get(Hx,'string'));
Hx=findobj('tag','Z2');
z2=str2num(get(Hx,'string'));
Hx=findobj('tag','kc');
kc=str2num(get(Hx,'string'));
Hx=findobj('tag','k1');
k1=str2num(get(Hx,'string'));
Hx=findobj('tag','kr');
kr=str2num(get(Hx,'string'));
Hx=findobj('tag','hac');
ha_c=str2num(get(Hx,'string'));
Hx=findobj('tag','hfc');
hf_c=str2num(get(Hx,'string'));
Hx=findobj('tag','c');
c_c=str2num(get(Hx,'string'));
Hx=findobj('tag','C1');
c1=str2num(get(Hx,'string'));
alfa=-0.6*pi/180; %蜗轮螺旋角
i=z1/z2; %传动比
d1=k1*A; %蜗杆喉部分度圆直径
m=(2*A-d1)/z2; %模数
ha=ha_c*m; hf=hf_c*m; c=c_c*m; %齿顶高,齿根高,顶隙
df1=d1-2*(hf+c); %蜗杆喉部齿根圆直径
da1=d1+2*ha; %蜗杆喉部齿顶圆直径
d2=2*A-d1; %蜗轮分度圆直径
da2=d2+2*ha; %蜗轮齿顶圆直径
df2=d2-2*(hf+c); %蜗轮齿跟圆直径
a2=da2/2*cos(alfa);
b2=da2/2*sin(alfa);
c2=-c1
R=7;
rf1=A-df1/2;
t1=-pi/5.5;t2=pi/5.5;
t=linspace(t1,t2,60);
d=linspace(0,2*pi,60)';
e1=((A*ones(size(t)))-(rf1*(cos(t))));
e2=A*ones(size(t))-rf1*cos(t);
X=cos(d)*e1;
Y=sin(d)*e2;
Z=ones(size(d))*rf1*sin(t);
mesh(Z,X,Y);
axis equal
axis off
shading interp; colormap(copper)
xlabel('\fontsize{20}\itz\rm_{1}\fontsize{18}/mm')
ylabel('\fontsize{20}\itx\rm_{1}\fontsize{18}/mm')
zlabel('\fontsize{20}\ity\rm_{1}\fontsize{18}/mm')
box off
hold on
for step=-1:3:11; %step控制螺旋线的稀疏程度和数量
u=step*c; %u - 滚子高度参数
fai2=linspace(-3.08*2*pi*i,3*2*pi*i,500); %fai2 - 蜗轮转角
fai1=fai2/i; %fai1 - 蜗杆转角
e1=sin(-alfa)*(i*b2-c2*cos(fai2))+cos(-alfa)*(c2*sin(fai2)-i*a2);
% e1=sin(fai2)*c2*cos(-alfa)-cos(fai2)*c2*sin(-alfa);
e2=sin(fai2)*(u*sin(-alfa)+b2)+cos(fai2)*(u*cos(-alfa)-a2)+A;
tan_theta=e2./e1;
theta=abs(atan(tan_theta));
theta=pi-theta;
x0=R*cos(theta);
y0=R*sin(theta);
z0=u*ones(size(fai1)); %u is a const
x1=-x0.*sin(fai1)+y0.*(cos(fai1).*sin(fai2)*cos(-alfa)-cos(fai1).*cos(fai2)*sin(-alfa))-a2.*cos(fai1).*cos(fai2)+b2.*cos(fai1).*sin(fai2)-c2.*sin(fai1)+A.*cos(fai1)+z0.*(cos(fai1).*cos(fai2)*cos(-alfa)+cos(fai1).*sin(fai2)*sin(-alfa));
y1=-x0.*cos(fai1)+y0.*(sin(fai1).*cos(fai2)*sin(-alfa)-sin(fai1).*sin(fai2)*cos(-alfa))+a2.*sin(fai1).*cos(fai2)-b2.*sin(fai1).*sin(fai2)-c2.*cos(fai1)-A.*sin(fai1)-z0.*(sin(fai1).*cos(fai2)*cos(-alfa)+sin(fai1).*sin(fai2)*sin(-alfa));
z1=-y0.*(sin(fai2)*sin(-alfa)+cos(fai2)*cos(-alfa))-a2*sin(fai2)-b2*cos(fai2)+z0.*(sin(fai2)*cos(-alfa)-cos(fai2)*sin(-alfa));
plot3(z1,y1,x1,'k')
hold on
end
jj=0; %写文件用循环变量
for fai2=linspace(-3.5*2*pi*i,3*2*pi*i,300); %fai2 - 蜗轮转角
fai1=fai2/i; %fai1 - 蜗杆转角
jj=jj+1;
theta=pi*(0:2000)/2000;
%theta赋初值,(0:pi)表示母面的左半侧,包络成蜗杆左齿面
B4=sin(-alfa)*sin(theta)*(c2*cos(fai2)-i*b2)+...
(i*a2-c2*sin(fai2))*sin(theta)*cos(-alfa)+...
(A-a2*cos(fai2)+b2*sin(fai2))*cos(theta);
B5=i*sin(theta)-cos(theta)*(cos(fai2)*cos(-alfa)+...
sin(fai2)*sin(-alfa));
u=B4./B5;
S=(find(u>-2&u<15)); %柱面参数u的边界条件
u=u(S);
theta=theta(S); %与u对应的theta
x0=R*cos(theta);
y0=R*sin(theta);
z0=u; %u is a variable
x1=cos(fai1)*cos(fai2)*(A*cos(fai2)+z0*cos(-alfa)-y0*sin(-alfa)-a2)+...
cos(fai1)*sin(fai2)*(b2+y0*cos(-alfa)+z0*sin(-alfa)+A*sin(fai2))-...
sin(fai1)*(c2+x0);
y1=sin(fai1)*cos(fai2)*(a2+y0*sin(-alfa)-z0*cos(-alfa)-A*cos(fai2))-...
sin(fai1)*sin(fai2)*(b2+y0*cos(-alfa)+z0*sin(-alfa)+A*sin(fai2))-...
cos(fai1)*(c2+x0);
z1=sin(fai2)*(A*cos(fai2)+z0*cos(-alfa)-y0*sin(-alfa)-a2)-cos(fai2)*...
(b2+y0*cos(-alfa)+z0*sin(-alfa)+A*sin(fai2));
plot3(z1,y1,x1,'k');
end;
hold off
function quanchimian_Callback(hObject, eventdata, handles)
function pushbutton15_Callback(hObject, eventdata, handles)
function pushbutton16_Callback(hObject, eventdata, handles)
close all
function text13_ButtonDownFcn(hObject, eventdata, handles)
function text13_CreateFcn(hObject, eventdata, handles)
function text13_DeleteFcn(hObject, eventdata, handles)
function figure1_WindowButtonDownFcn(hObject, eventdata, handles)
function figure1_ResizeFcn(hObject, eventdata, handles)
function figure1_CreateFcn(hObject, eventdata, handles)
function uipanel1_CreateFcn(hObject, eventdata, handles)
function uipanel1_ButtonDownFcn(hObject, eventdata, handles)
function figure1_KeyPressFcn(hObject, eventdata, handles)
还有untitled1的m文件程序如下
[[i] 本帖最后由 sigma665 于 2008-10-21 19:08 编辑 [/i]] |
|