I am an engineering student, fairly new to MATLAB. I have created a GUI for a class that calculates voltages and amperages of a specified circuit. I wish to display the amperages as (A) and (mA). The program currently calculates the data and displays it in static text boxes. I am using a button group with two radio buttons inside, working exclusively. I have used selectionChangeFcn
in the following manner to control the buttons.
function group_SelectionChangeFcn(hObject, eventdata, handles)
switch get(eventdata.NewValue,'Tag') % Get Tag of selected object.
case 'radiobutton1'
var=1;
set(handles.text1, 'String', '(A)');
case 'radiobutton2'
var=1000;
set(handles.text1, 'String', '(mA)');
otherwise
end
Choosing one button or the other changes text in the static text boxes, and assigns a value to a variable. The bulk of the programming code is executed under a pushbutton. All of the variables are contained in this code, and are filled from edit boxes. Everything else works great so far. Within the cases I have (A) or (mA) outputted to a static text box, and you can see that operating the buttons does in fact display different values.
My problem is this; I wish to use variable var
in the code to multiply my answer data so that it reads in either A or mA. Like this;
set (handles.text36,'string',num2str(ir1*var,'%20.3f'))
I cannot get this to work, however, the error says that var is undefined. It seems to do this in all circumstances. I have experimented with moving the code to different locations, but I cannot get it to work. Any help or ideas would be appreciated.