⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zhengshi.m

📁 一个matlab的表面轮廓滤波程序
💻 M
📖 第 1 页 / 共 2 页
字号:
center=[suma sumb];
dia=sum(wi)/n;
newri=wi;
set(handles.WC2,'string',wc);
axes(handles.axes3);
hold on
R=str2num(get(handles.R,'string'));
r=dia+R;
x=r.*cos(siet);
y=r.*sin(siet);
plot(x,y,'r')
hold off
% --- Executes on button press in NJ.
function WJ_Callback(hObject, eventdata, handles)          %最小外接圆法评定
% hObject    handle to NJ (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global t;
wi=t;
n=size(wi',1);
siet=linspace(0,360-360/n,n)/180*pi;
suma=0; sumb=0;
%%先最小二乘预处理
a=2/n*sum(wi.*cos(siet));
b=2/n*sum(wi.*sin(siet));
suma=suma+a;    sumb=sumb+b;
wi=wi-a*cos(siet)-b*sin(siet);
%开始最小外接
maxwi=max(wi);
objfun=[-1 0 0]; 
ci=[(ones(1,n))' (cos(siet))'  (sin(siet))' ]; 
rb=wi;   
[xval,least_r]=linprog(objfun,ci,rb);
wi=wi-xval(2,1)*cos(siet)-xval(3,1)*sin(siet);
suma=suma+xval(2,1);    sumb=sumb+xval(3,1);
wc=max(wi)-min(wi);
center=[suma sumb];
maxdia=min(wi);
newri=wi;
set(handles.WC4,'string',wc);
axes(handles.axes4);
hold on
R=str2num(get(handles.R,'string'));
r=max(wi)+R;
x=r.*cos(siet);
y=r.*sin(siet);
plot(x,y,'b')
hold off
% --- Executes on button press in WJ.
function NJ_Callback(hObject, eventdata, handles)          %最大内接圆法评定
% hObject    handle to WJ (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global t;
wi=t;
n=size(wi',1);
siet=linspace(0,360-360/n,n)/180*pi;
suma=0; sumb=0;
a=2/n*sum(wi.*cos(siet));
b=2/n*sum(wi.*sin(siet));
suma=suma+a;    sumb=sumb+b;
wi=wi-a*cos(siet)-b*sin(siet);
maxwi=max(wi);
objfun=[1 0 0];
add_i=-eye(n);
ci=[-(ones(1,n))' -(cos(siet))'  -(sin(siet))' ];  
rb=-wi';
lb=[0,-maxwi,-maxwi];
mb=[1.5*maxwi,maxwi,maxwi];
[xval,least_r]=linprog(objfun,ci,rb,[],[],lb,mb);
wi=wi-xval(2,1)*cos(siet)-xval(3,1)*sin(siet);
suma=suma+xval(2,1);    sumb=sumb+xval(3,1);
wc=max(wi)-min(wi);
center=[suma sumb];
mindia=max(wi);
newri=wi;
set(handles.WC3,'string',wc);
axes(handles.axes4);
hold on
R=str2num(get(handles.R,'string'));
r=min(wi)+R;
x=r.*cos(siet);
y=r.*sin(siet);
plot(x,y,'r')
hold off
function WC1_Callback(hObject, eventdata, handles)
% hObject    handle to WC1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of WC1 as text
%        str2double(get(hObject,'String')) returns contents of WC1 as a double
% --- Executes during object creation, after setting all properties.
function WC1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to WC1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
function save_Callback(hObject, eventdata, handles)
% hObject    handle to save (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
[filename, pathname] = uiputfile( {'*.mat'}, 'Save as');
% --------------------------------------------------------------------
function close_Callback(hObject, eventdata, handles)
% hObject    handle to close (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
close
% --------------------------------------------------------------------
function file_Callback(hObject, eventdata, handles)
% hObject    handle to file (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function XX_Callback(hObject, eventdata, handles)              %详细信息介绍
% hObject    handle to XX (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
%--------------------help------------------
  dlg2 = dialog('Position',[158 202 530 307], 'Name', '介绍', ...
              'WindowStyle', 'normal');
X='---------------------------------------------------------------------';
uicontrol('Parent',dlg2, 'Position',[8 280 550 20], 'String',X, ...
                    'Style','text');
uicontrol('Parent',dlg2, 'Position',[8 250 550 20], 'String',X, ...
                    'Style','text');
%str='about the version of this system';
str='基于MATLAB的圆度滤波操作';
 uicontrol('Parent',dlg2, 'Position',[8 265 550 20], 'String',str, ...
                    'Style','text','fontsize',12);
uicontrol('Parent',dlg2, 'Position',[45 50 450 200],'Style','frame');
str1='本课题通过利用MATLAB对圆度数字信号进行滤波操作获得所需的数字信号,随后对该信号采用不同的误差评定算法的函数模型计算其圆度误差并进行分析,最后编程实现各过程和求解结果的可视化(即用户界面设计)。';
str2='指导老师:张琳娜      学生:卢吉水';
str3='时间:2006.5';
str4='地点:郑州大学机械工程学院';
uicontrol('Parent',dlg2, 'Position',[120 140 320 100], 'String',str1, ...
                    'Style','text','fontsize',11);
uicontrol('Parent',dlg2, 'Position',[300 95 120 45], 'String',str2, ...
                    'Style','text','fontsize',11);
uicontrol('Parent',dlg2, 'Position',[310 80 120 20], 'String',str3, ...
                    'Style','text','fontsize',11);
uicontrol('Parent',dlg2, 'Position',[260 60 200 20], 'String',str4, ...
                    'Style','text','fontsize',11);
% --------------------------------------------------------------------




function wc4_Callback(hObject, eventdata, handles)
% hObject    handle to wc4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of wc4 as text
%        str2double(get(hObject,'String')) returns contents of wc4 as a double


% --- Executes during object creation, after setting all properties.
function wc4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to wc4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function wc3_Callback(hObject, eventdata, handles)
% hObject    handle to wc3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of wc3 as text
%        str2double(get(hObject,'String')) returns contents of wc3 as a double


% --- Executes during object creation, after setting all properties.
function wc3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to wc3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function wc2_Callback(hObject, eventdata, handles)
% hObject    handle to wc2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of wc2 as text
%        str2double(get(hObject,'String')) returns contents of wc2 as a double


% --- Executes during object creation, after setting all properties.
function wc2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to wc2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function WC2_Callback(hObject, eventdata, handles)
% hObject    handle to WC2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of WC2 as text
%        str2double(get(hObject,'String')) returns contents of WC2 as a double


% --- Executes during object creation, after setting all properties.
function WC2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to WC2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function WC3_Callback(hObject, eventdata, handles)
% hObject    handle to WC3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of WC3 as text
%        str2double(get(hObject,'String')) returns contents of WC3 as a double


% --- Executes during object creation, after setting all properties.
function WC3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to WC3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function WC4_Callback(hObject, eventdata, handles)
% hObject    handle to WC4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of WC4 as text
%        str2double(get(hObject,'String')) returns contents of WC4 as a double


% --- Executes during object creation, after setting all properties.
function WC4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to WC4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -