1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
function editFrequence_Callback(hObject, eventdata, handles)
% hObject handle to editFrequence (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get the new value for the Frequency.
NewStrVal = get(hObject, 'String');
NewVal = str2double(NewStrVal);
% Check that the entered value falls within the allowable range.
if isempty(NewVal) || (NewVal< 0) || (NewVal>50000),
% Revert to last value, as indicated by the Slider.
OldVal = get(handles.sliderFrequence,'Value');
set(hObject, 'String',OldVal)
else % Use new frequency value
% Set the value of the Slider to the new value.
set(handles.sliderFrequence,'Value',NewVal)
% Set the Frequency parameter of the Sine Wave Block
% to the new value.
set_param('StageVrai2/Sine Wave','Frequency',NewStrVal)
end |