📄 scan_mode.m
字号:
function varargout = scan_mode(varargin)
% SCAN_MODE M-file for scan_mode.fig
% SCAN_MODE, by itself, creates a new SCAN_MODE or raises the existing
% singleton*.
%
% H = SCAN_MODE returns the handle to a new SCAN_MODE or the handle to
% the existing singleton*.
%
% SCAN_MODE('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in SCAN_MODE.M with the given input arguments.
%
% SCAN_MODE('Property','Value',...) creates a new SCAN_MODE or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before scan_mode_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to scan_mode_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 scan_mode
% Last Modified by GUIDE v2.5 04-Dec-2007 17:55:21
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @scan_mode_OpeningFcn, ...
'gui_OutputFcn', @scan_mode_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 scan_mode is made visible.
function scan_mode_OpeningFcn(hObject, eventdata, 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 scan_mode (see VARARGIN)
% Choose default command line output for scan_mode
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes scan_mode wait for user response (see UIRESUME)
set(handles.figure1,'WindowStyle','modal')
% uiwait(handles.figure1);
global amp_min amp_max pha_max pha_min
amp_min=-40;
amp_max=10;
pha_max=360;
pha_min=0;
str=sprintf('range:%d~%d db',amp_min,amp_max);
set(handles.text_label1,'string',str);
str=sprintf('range:%d~%d deg',pha_min,pha_max);
set(handles.text_label2,'string',str);
% Initialzing the selection panel
uipanel2_SelectionChangeFcn(handles.mode1, eventdata, handles);
% --- Outputs from this function are returned to the command line.
function varargout = scan_mode_OutputFcn(hObject, eventdata, 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;
uiwait(handles.figure1);
function amp_Callback(hObject, eventdata, handles)
% hObject handle to amp (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 amp as text
% str2double(get(hObject,'String')) returns contents of amp as a double
global amp_min amp_max pha_max pha_min
user_entry = str2double(get(hObject,'string'));
if isnan(user_entry) | user_entry>amp_max |user_entry<amp_min
errordlg('You must enter a numeric value','Bad Input','modal');
set(hObject,'string','-20');
return
end
% --- Executes during object creation, after setting all properties.
function amp_CreateFcn(hObject, eventdata, handles)
% hObject handle to amp (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
% --- Executes on slider movement.
function pha_slider_Callback(hObject, eventdata, handles)
% hObject handle to pha_slider (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
global pha_max pha_min
slider_value = get(hObject,'Value');
var=round(slider_value*(pha_max-pha_min)+pha_min);
set(handles.pha,'string',num2str(var));
% --- Executes during object creation, after setting all properties.
function pha_slider_CreateFcn(hObject, eventdata, handles)
% hObject handle to pha_slider (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
function pha_Callback(hObject, eventdata, handles)
% hObject handle to pha (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 pha as text
% str2double(get(hObject,'String')) returns contents of pha as a double
global pha_max pha_min
user_entry = str2double(get(hObject,'string'));
if isnan(user_entry) | user_entry>pha_max |user_entry<pha_min
errordlg('You must enter a numeric value','Bad Input','modal');
set(hObject,'string','0');
return
end
% --- Executes during object creation, after setting all properties.
function pha_CreateFcn(hObject, eventdata, handles)
% hObject handle to pha (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
% --- Executes on slider movement.
function slider2_Callback(hObject, eventdata, handles)
% hObject handle to slider2 (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
% --- Executes during object creation, after setting all properties.
function slider2_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% 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)
global model_num param_amp param_pha
switch(model_num)
case 1
param_amp=str2num(get(handles.amp,'string'));
param_pha=str2num(get(handles.pha,'string'));
if isnan(param_amp) | isnan(param_pha)
errordlg('You must enter a numeric value','Bad Input','modal')
return
end
case 2
param_amp=str2num(get(handles.amp,'string'));
var1=str2num(get(handles.start2,'string'));
var2=str2num(get(handles.end2,'string'));
var3=str2num(get(handles.step2,'string'));
param_pha=var1:var3:var2;
if isnan(param_amp) | isnan(param_pha)
errordlg('You must enter a numeric value','Bad Input','modal')
return
end
case 3
param_pha=str2num(get(handles.pha,'string'));
var1=str2num(get(handles.start1,'string'));
var2=str2num(get(handles.end1,'string'));
var3=str2num(get(handles.step1,'string'));
param_amp=var1:var3:var2;
if isnan(param_amp) | isnan(param_pha)
errordlg('You must enter a numeric value','Bad Input','modal')
return
end
case 4
var1=str2num(get(handles.start1,'string'));
var2=str2num(get(handles.end1,'string'));
var3=str2num(get(handles.step1,'string'));
param_amp=var1:var3:var2;
var1=str2num(get(handles.start2,'string'));
var2=str2num(get(handles.end2,'string'));
var3=str2num(get(handles.step2,'string'));
param_pha=var1:var3:var2;
otherwise
param_amp=[];
param_pha=[];
end
save param_scanning model_num param_amp param_pha
delete(handles.figure1);
% --------------------------------------------------------------------
function uipanel2_SelectionChangeFcn(hObject, eventdata, handles)
% hObject handle to uipanel2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global model_num param_amp param_pha
global amp_min amp_max pha_max pha_min
switch get(hObject,'Tag') % Get Tag of selected object
case 'mode1'
model_num=1;
set(handles.amp,'visible','on');
set(handles.amp,'string',amp_min);
set(handles.amp_slider,'visible','on');
set(handles.pha,'visible','on');
set(handles.pha,'string',pha_min);
set(handles.pha_slider,'visible','on');
% Text: start end step
set(handles.str1,'visible','off');
set(handles.str2,'visible','off');
set(handles.str3,'visible','off');
set(handles.str4,'visible','off');
set(handles.str5,'visible','off');
set(handles.str6,'visible','off');
% edit: start end step
set(handles.start1,'visible','off');
set(handles.end1,'visible','off');
set(handles.step1,'visible','off');
set(handles.start2,'visible','off');
set(handles.end2,'visible','off');
set(handles.step2,'visible','off');
case 'mode2'
model_num=2;
set(handles.amp,'visible','on');
set(handles.amp,'string',amp_min);
set(handles.amp_slider,'visible','on');
set(handles.pha,'visible','off');
set(handles.pha_slider,'visible','off');
% Text: start end step
set(handles.str1,'visible','off');
set(handles.str2,'visible','off');
set(handles.str3,'visible','off');
set(handles.str4,'visible','on');
set(handles.str5,'visible','on');
set(handles.str6,'visible','on');
% edit: start end step
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -