|
Greetings All
I'm trying to use a slider to adjust the frequency of an audio signal
that is played out my audio card in "realtime" using matlab. I keep
getting an error reference to non-existent field 'freq'.
this is the line of code it saying has the error
set(handles.freq,'Value',sliderValue);
The thing is I created the freq variable right above it. Any
suggestions/ should I be doing it this way?
example code below:
function slider1_Callback(hObject, eventdata, handles)
sliderValue = get(handles.slider1,'Value');
%puts the slider value into the edit text component
set(handles.sliderValue_editText,'String', num2str(sliderValue));
freq=1;
set(handles.freq,'Value',sliderValue); %sets freq when slider changes
<-------error it refers too
% Update handles structure
guidata(hObject, handles);
function sliderValue_editText_Callback(hObject, eventdata, handles)
sliderValue = get(handles.sliderValue_editText,'String');
%convert from string to number if possible, otherwise returns empty
sliderValue = str2num(sliderValue);
%if user inputs something is not a number, or if the input is less
than 0
%or greater than 100, then the slider value defaults to 0
if (isempty(sliderValue) || sliderValue < 0 || sliderValue > 300)
set(handles.slider1,'Value',0);
set(handles.freq,'Value',1); %sets freq when slider changes
set(handles.sliderValue_editText,'String','0');
else
set(handles.slider1,'Value',sliderValue);
set(handles.freq,'Value',sliderValue); %sets freq when slider
changes
end
|