Code covered by the BSD License  

Highlights from
Laboratory froth flotation machine automation GUI

image thumbnail

Laboratory froth flotation machine automation GUI

by

 

This program was designed to work as a controller for upgraded DV-2 laboratory flotation machine.

config(varargin)
function varargout = config(varargin)
% CONFIG M-file for config.fig
%      CONFIG, by itself, creates a new CONFIG or raises the existing
%      singleton*.
%
%      H = CONFIG returns the handle to a new CONFIG or the handle to
%      the existing singleton*.
%
%      CONFIG('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in CONFIG.M with the given input arguments.
%
%      CONFIG('Property','Value',...) creates a new CONFIG or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before config_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to config_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help config

% Last Modified by GUIDE v2.5 01-Feb-2011 15:00:40

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @config_OpeningFcn, ...
                   'gui_OutputFcn',  @config_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
% End initialization code - DO NOT EDIT


% --- Executes just before config is made visible.
function config_OpeningFcn(hObject, ~, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to config (see VARARGIN)

% Choose default command line output for config
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes config wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = config_OutputFcn(~, ~, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, ~, handles) %#ok<*DEFNU>
% 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)
%saveData = cell(17, 2);
saveData = cell(9, 2);

%saveData(10,1) = {'ai_card:'};
%saveData(10,2) = num2cell(handles.ai_card);
%saveData(11,1) = {'ao_card:'};
%saveData(11,2) = num2cell(handles.ao_card);
%saveData(12,1) = {'rpm_ao_ch:'};
%saveData(12,2) = num2cell(handles.rpm_ao_ch);
%saveData(13,1) = {'lpm_ao_ch:'};
%saveData(13,2) = num2cell(handles.lpm_ao_ch);
%saveData(14,1) = {'pH_ai_ch:'};
%saveData(14,2) = num2cell(handles.pH_ai_ch);
%saveData(15,1) = {'lpm_ai_ch:'};
%saveData(15,2) = num2cell(handles.lpm_ai_ch);
%saveData(16,1) = {'temp_ai_ch:'};
%saveData(16,2) = num2cell(handles.temp_ai_ch);
%saveData(17,1) = {'rpm_ai_ch:'};
%saveData(17,2) = num2cell(handles.rpm_ai_ch);

saveData(1,1) = {'pH_min:'};
saveData(1,2) = num2cell(handles.pH_min);
saveData(2,1) = {'pH_max:'};
saveData(2,2) = num2cell(handles.pH_max);
saveData(3,1) = {'lpm_min:'};
saveData(3,2) = num2cell(handles.lpm_min);
saveData(4,1) = {'lpm_max:'};
saveData(4,2) = num2cell(handles.lpm_max);
saveData(5,1) = {'temp_min:'};
saveData(5,2) = num2cell(handles.temp_min);
saveData(6,1) = {'temp_max:'};
saveData(6,2) = num2cell(handles.temp_max);
saveData(7,1) = {'rpm_min:'};
saveData(7,2) = num2cell(handles.rpm_min);
saveData(8,1) = {'rpm_max:'};
saveData(8,2) = num2cell(handles.rpm_max);
saveData(9,1) = {'pH_ohm:'};
saveData(9,2) = num2cell(handles.pH_ohm);
saveData(10,1) = {'lpm_ohm:'};
saveData(10,2) = num2cell(handles.lpm_ohm);
saveData(11,1) = {'temp_ohm:'};
saveData(11,2) = num2cell(handles.temp_ohm);
saveData(12,1) = {handles.default_save_path};
saveData(12,2) = num2cell(1);

path = pwd();
cd(handles.default_save_path)
[filename, pathname] = uiputfile('*.conf', 'Save configuration to file');    
cd(path);
if isnumeric(filename) == 1 || isnumeric(pathname) == 1 
else
   dlmcell([pathname filename], saveData, ' ');
end
guidata(hObject, handles);


function edit1_Callback(hObject, ~, handles)
% hObject    handle to edit1 (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 edit1 as text
%        str2double(get(hObject,'String')) returns contents of edit1 as a double
val = str2double(get(hObject,'String'));
if isnan(val) == 1
   uiwait(errordlg('Enter numerical value!', 'Error', 'modal'));
   set(handles.edit1, 'String', handles.pH_min);
elseif val >= handles.pH_max
   uiwait(errordlg('Value equal to 0 V must be lower than value equal to 5 V !', 'Error', 'modal'));
   set(handles.edit1, 'String', handles.pH_min);
else
   handles.pH_min = val;
end
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, ~, handles)
% hObject    handle to edit1 (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
guidata(hObject, handles);


function edit2_Callback(hObject, ~, handles)
% hObject    handle to edit2 (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 edit2 as text
%        str2double(get(hObject,'String')) returns contents of edit2 as a double
val = str2double(get(hObject,'String'));
if isnan(val) == 1
   uiwait(errordlg('Enter numerical value!', 'Error', 'modal'));
   set(handles.edit2, 'String', handles.pH_max);
elseif val <= handles.pH_min
   uiwait(errordlg('Value equal to 5 V must be higher than value equal to 0 V !', 'Error', 'modal'));
   set(handles.edit2, 'String', handles.pH_max);
else
   handles.pH_max = val;
end
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, ~, handles)
% hObject    handle to edit2 (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
guidata(hObject, handles);


function edit3_Callback(hObject, ~, handles)
% hObject    handle to edit3 (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 edit3 as text
%        str2double(get(hObject,'String')) returns contents of edit3 as a double
val = str2double(get(hObject,'String'));
if isnan(val) == 1
   uiwait(errordlg('Enter numerical value!', 'Error', 'modal'));
   set(handles.edit3, 'String', handles.lpm_min);
elseif val >= handles.lpm_max
   uiwait(errordlg('Value equal to 0 V must be lower than value equal to 5 V !', 'Error', 'modal'));
   set(handles.edit3, 'String', handles.lpm_min);
else
   handles.lpm_min = val;
end
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, ~, handles)
% hObject    handle to edit3 (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
guidata(hObject, handles);


function edit4_Callback(hObject, ~, handles)
% hObject    handle to edit4 (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 edit4 as text
%        str2double(get(hObject,'String')) returns contents of edit4 as a double
val = str2double(get(hObject,'String'));
if isnan(val) == 1
   uiwait(errordlg('Enter numerical value!', 'Error', 'modal'));
   set(handles.edit4, 'String', handles.pH_max);
elseif val <= handles.lpm_min
   uiwait(errordlg('Value equal to 5 V must be higher than value equal to 0 V !', 'Error', 'modal'));
   set(handles.edit4, 'String', handles.pH_max);
else
   handles.lpm_max = val;
end
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, ~, 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
guidata(hObject, handles);


function edit5_Callback(hObject, ~, 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)

% Hints: get(hObject,'String') returns contents of edit5 as text
%        str2double(get(hObject,'String')) returns contents of edit5 as a double
val = str2double(get(hObject,'String'));
if isnan(val) == 1
   uiwait(errordlg('Enter numerical value!', 'Error', 'modal'));
   set(handles.edit5, 'String', handles.temp_min);
elseif val >= handles.temp_max
   uiwait(errordlg('Value equal to 5 V must be higher than value equal to 0 V !', 'Error', 'modal'));
   set(handles.edit5, 'String', handles.temp_min);
else
   handles.temp_min = val;
end
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, ~, 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
guidata(hObject, handles);


function edit6_Callback(hObject, ~, 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)

% Hints: get(hObject,'String') returns contents of edit6 as text
%        str2double(get(hObject,'String')) returns contents of edit6 as a double
val = str2double(get(hObject,'String'));
if isnan(val) == 1
   uiwait(errordlg('Enter numerical value!', 'Error', 'modal'));
   set(handles.edit6, 'String', handles.temp_max);
elseif val <= handles.temp_min
   uiwait(errordlg('Value equal to 5 V must be higher than value equal to 0 V !', 'Error', 'modal'));
   set(handles.edit6, 'String', handles.temp_max);
else
   handles.temp_max = val;
end
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, ~, 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
guidata(hObject, handles);


function edit7_Callback(hObject, ~, handles)
% hObject    handle to edit7 (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 edit7 as text
%        str2double(get(hObject,'String')) returns contents of edit7 as a double

guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function edit7_CreateFcn(hObject, ~, handles)
% hObject    handle to edit7 (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
guidata(hObject, handles);

% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, ~, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
path = pwd();
cd(handles.default_save_path)
[filename, pathname] = uigetfile('*.conf', 'Load configuration from file');    
cd(path);
if isnumeric(filename) == 1 || isnumeric(pathname) == 1 
else
   [names, values] = textread([pathname filename], '%s%n');
end

handles.pH_min = values(1);
handles.pH_max = values(2);
handles.lpm_min = values(3);
handles.lpm_max = values(4);
handles.temp_min = values(5);
handles.temp_max = values(6);
handles.rpm_min = values(7);
handles.rpm_max = values(8);
handles.pH_ohm = values(9);
handles.lpm_ohm = values(10);
handles.temp_ohm = values(11);

handles.default_save_path = names(12);

set(handles.edit1, 'String', num2str(handles.pH_min, '%2.4f'));
set(handles.edit2, 'String', num2str(handles.pH_max, '%2.4f'));
set(handles.edit3, 'String', num2str(handles.lpm_min, '%2.4f'));
set(handles.edit4, 'String', num2str(handles.lpm_max, '%2.4f'));
set(handles.edit5, 'String', num2str(handles.temp_min, '%2.4f'));
set(handles.edit6, 'String', num2str(handles.temp_max, '%2.4f'));
set(handles.edit8, 'String', num2str(handles.rpm_min, '%4.2f'));
set(handles.edit9, 'String', num2str(handles.rpm_max, '%4.2f'));
set(handles.edit10, 'String', num2str(handles.pH_ohm, '%3.3f'));
set(handles.edit11, 'String', num2str(handles.lpm_ohm, '%3.3f'));
set(handles.edit12, 'String', num2str(handles.temp_ohm, '%3.3f'));

set(handles.edit7, 'String', handles.default_save_path);

guidata(hObject, handles);

% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, ~, handles)
% hObject    handle to pushbutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
maingui_handle = main;
maingui_data_handles = guidata(maingui_handle);
maingui_data_handles.pH_min = handles.pH_min;
maingui_data_handles.pH_max = handles.pH_max;
maingui_data_handles.lpm_min = handles.lpm_min;
maingui_data_handles.lpm_max = handles.lpm_max;
maingui_data_handles.temp_min = handles.temp_min;
maingui_data_handles.temp_max = handles.temp_max;
maingui_data_handles.rpm_min = handles.rpm_min;
maingui_data_handles.rpm_max = handles.rpm_max;
maingui_data_handles.pH_ohm = handles.pH_ohm;
maingui_data_handles.lpm_ohm = handles.lpm_ohm;
maingui_data_handles.temp_ohm = handles.temp_ohm;

maingui_data_handles.default_save_path = handles.default_save_path;
guidata(maingui_handle, maingui_data_handles);
guidata(hObject, handles);

% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(~, ~, ~)
% hObject    handle to pushbutton4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
clear = questdlg('Do you want to close this dialog? Unsaved data will be lost.', 'Confirmation', 'No');
if strcmp(clear, 'Yes') == 1
    delete(config);
end

function edit8_Callback(hObject, ~, handles)
% hObject    handle to edit8 (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 edit8 as text
%        str2double(get(hObject,'String')) returns contents of edit8 as a double
val = str2double(get(hObject,'String'));
if isnan(val) == 1
   uiwait(errordlg('Enter numerical value!', 'Error', 'modal'));
   set(handles.edit8, 'String', handles.rpm_min);
%elseif val < 0 == 1
%   uiwait(errordlg('Enter numerical value greater than 0 rpm!', 'Error', 'modal'));
%   set(handles.edit8, 'String', handles.rpm_min);
elseif val >= handles.rpm_max
   uiwait(errordlg('Value equal to 5 V must be higher than value equal to 0 V !', 'Error', 'modal'));
   set(handles.edit8, 'String', handles.rpm_min);
else
   handles.rpm_min = val;
end
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function edit8_CreateFcn(hObject, ~, handles)
% hObject    handle to edit8 (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
guidata(hObject, handles);


function edit9_Callback(hObject, ~, handles)
% hObject    handle to edit9 (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 edit9 as text
%        str2double(get(hObject,'String')) returns contents of edit9 as a double
val = str2double(get(hObject,'String'));
if isnan(val) == 1
   uiwait(errordlg('Enter numerical value!', 'Error', 'modal'));
   set(handles.edit9, 'String', handles.rpm_max);
elseif val < 0 == 1
   uiwait(errordlg('Enter numerical value greater than 0 rpm!', 'Error', 'modal'));
   set(handles.edit9, 'String', handles.rpm_max);
elseif val <= handles.rpm_min
   uiwait(errordlg('Value equal to 5 V must be higher than value equal to 0 V !', 'Error', 'modal'));
   set(handles.edit9, 'String', handles.rpm_max);
else
   handles.rpm_max = val;
end
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function edit9_CreateFcn(hObject, ~, handles)
% hObject    handle to edit9 (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
guidata(hObject, handles);

% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, ~, handles)
% hObject    handle to pushbutton5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
directoryname = uigetdir;
if directoryname == '0'
else
    handles.default_save_path = directoryname;
    set(handles.edit7, 'String', handles.default_save_path);
end
guidata(hObject, handles);



function edit10_Callback(hObject, ~, handles)
% hObject    handle to edit10 (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 edit10 as text
%        str2double(get(hObject,'String')) returns contents of edit10 as a double
val = str2double(get(hObject,'String'));
if isnan(val) == 1
   uiwait(errordlg('Enter numerical value!', 'Error', 'modal'));
   set(handles.edit1, 'String', handles.pH_ohm);
elseif val <= 0
   uiwait(errordlg('Value of resistance must be positive!', 'Error', 'modal'));
   set(handles.edit1, 'String', handles.pH_ohm);
else
   handles.pH_ohm = val;
end
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function edit10_CreateFcn(hObject, ~, handles)
% hObject    handle to edit10 (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
guidata(hObject, handles);


function edit11_Callback(hObject, ~, handles)
% hObject    handle to edit11 (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 edit11 as text
%        str2double(get(hObject,'String')) returns contents of edit11 as a double
val = str2double(get(hObject,'String'));
if isnan(val) == 1
   uiwait(errordlg('Enter numerical value!', 'Error', 'modal'));
   set(handles.edit1, 'String', handles.lpm_ohm);
elseif val <= 0
   uiwait(errordlg('Value of resistance must be positive!', 'Error', 'modal'));
   set(handles.edit1, 'String', handles.lpm_ohm);
else
   handles.lpm_ohm = val;
end
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function edit11_CreateFcn(hObject, ~, handles)
% hObject    handle to edit11 (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
guidata(hObject, handles);


function edit12_Callback(hObject, ~, handles)
% hObject    handle to edit12 (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 edit12 as text
%        str2double(get(hObject,'String')) returns contents of edit12 as a double
val = str2double(get(hObject,'String'));
if isnan(val) == 1
   uiwait(errordlg('Enter numerical value!', 'Error', 'modal'));
   set(handles.edit1, 'String', handles.temp_ohm);
elseif val <= 0
   uiwait(errordlg('Value of resistance must be positive!', 'Error', 'modal'));
   set(handles.edit1, 'String', handles.temp_ohm);
else
   handles.temp_ohm = val;
end
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function edit12_CreateFcn(hObject, ~, handles)
% hObject    handle to edit12 (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
guidata(hObject, handles);

Contact us