How to set specific values from 3 edittextbox to 4 radio button (total of 12 static outputs).

1 view (last 30 days)
Hi MatLab Users. I need some help. I have 4 radio buttons tag as channels (Channel1-4) and 3 editboxes which contains (Freq,Ampl, and Offset) to be Applied and also a display (Static Text) of all channels contains of its values.
How can I set the value of Frequency, Amplitude, and Offset of the specific radio button (from Channel1 to 4) without interrupting the other radio button and display it as Static Text.
Any ideas how to *set/*get handles this values
I'm trying to implement also the use of If-else button
like on Frequency set button under it i applied:
hz=get(handles.editFrequency,'String')
if hObject ==handles.channel1
a=get(handles.editFrequency, hz)
set(handles.editStatic1, 'String', a)
elseif hObject ==handles.channel2
b=get(handles.editFrequency, hz)
set(handles.editStatic2, 'String', b)
elseif hObject ==handles.channel3
c=get(handles.editFrequency, hz)
set(handles.editStatic3, 'String', c)
elseif hObject ==handles.channel4
d=get(handles.editFrequency, hz)
set(handles.editStatic4, 'String', d)
end
yet when i changed the Channel number the values are still on edisStatic1.
editstatic is the static text just to display the given values. editFrequency is the textbox name for editing frequency values
any ideas how to set the values of Freq., Amplitude, and Offset w/o Interrupting other values. thanks. I need some syntax Thanks!

Accepted Answer

Geoff Hayes
Geoff Hayes on 4 Apr 2015
Charlston - the line of code (presumably) returns the user entered frequency (in Hertz)
hz=get(handles.editFrequency,'String')
The code then seems to check to see which radio button was just selected (this assumes the above block of code is within a panel/button group _SelectionChangeFcn callback). If, for example, the first channel was selected then the code that fires is
if hObject == handles.channel1
a=get(handles.editFrequency, hz)
set(handles.editStatic1, 'String', a)
What do you expect a to be? You already have the value/string for the user entered frequency in the hz and so
a=get(handles.editFrequency, hz)
will fail because you are trying to get the hz property (which won't exist) for the editFrequency control. If you want to just set the editStatic1 control to the current frequency, then just do
if hObject == handles.channel1
set(handles.editStatic1, 'String', hz);
Try doing the same for the other channels (radio buttons).

More Answers (0)

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!