Материал: Тема8_Matlab

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам

function edit4_CreateFcn(hObject, eventdata, handles)

% hObject

handle to edit4 (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 edit5_Callback(hObject, eventdata, handles)

% hObject

handle to edit5 (see GCBO)

% eventdata

reserved - to be defined in a future version of MATLAB

% handles

structure with handles and user data (see GUIDATA)

global d

 

 

d(4)=str2num(get(hObject,'string')) if

(~isempty(get(handles.edit2,'string'))&&~isempty(get(handles.edit3,'string')) &&~isempty(get(handles.edit4,'string'))&&~isempty(get(handles.edit5,'string') )&&~isempty(get(handles.edit6,'string')))

set(handles.pushbutton1,'visible','on') set(handles.text3,'visible','off')

end

%Hints: get(hObject,'String') returns contents of edit5 as text

%str2double(get(hObject,'String')) returns contents of edit5 as

a double

%--- Executes during object creation, after setting all properties. function edit5_CreateFcn(hObject, eventdata, handles)

% hObject

handle to edit5 (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 edit6_Callback(hObject, eventdata, handles)

% hObject

handle to edit6 (see GCBO)

% eventdata

reserved - to be defined in a future version of MATLAB

% handles

structure with handles and user data (see GUIDATA)

global d

 

 

d(5)=str2num(get(hObject,'string')) if

(~isempty(get(handles.edit2,'string'))&&~isempty(get(handles.edit3,'string')) &&~isempty(get(handles.edit4,'string'))&&~isempty(get(handles.edit5,'string') )&&~isempty(get(handles.edit6,'string')))

set(handles.pushbutton1,'visible','on') set(handles.text3,'visible','off')

end

%Hints: get(hObject,'String') returns contents of edit6 as text

%str2double(get(hObject,'String')) returns contents of edit6 as

a double

%--- Executes during object creation, after setting all properties.

6

function edit6_CreateFcn(hObject, eventdata, handles)

% hObject

handle to edit6 (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

% --- Executes on button press in pushbutton1.

function pushbutton1_Callback(hObject, eventdata, handles)

% hObject

handle to pushbutton1 (see GCBO)

% eventdata

reserved - to be defined in a future version of MATLAB

% handles

structure with handles and user data (see GUIDATA)

global Matr d n k srednee=sum(d)/5

if (Matr(n,1)<=srednee) && (Matr(n,2)>=srednee) k=1

set(handles.text3,'string','Требования по твердости выполнены') set(handles.text3,'visible','on')

else k=0

set(handles.text3,'string','Требования по твердости не

выполнены')

set(handles.text3,'visible','on')

end fp=fopen('print2.txt','w')

fprintf(fp,'Деталь № %2.0d \n',n)

fprintf(fp,'Граничные значения твердости от %3.0d до %3.0d \n',Matr(n,1),Matr(n,2))

fprintf(fp,'Измеренные значения:%s ',num2str(d)) if k==1

fprintf(fp,'\nСуждение: Требования по твердости выполнены') else

fprintf(fp,'\nСуждение: Требования по твердости не выполнены')

end

fclose(fp)

7