A list,

Simulation of undulating optical system based on MATLAB GUI

Ii. Source code

Function varargout = bysj2(varargin) % bysj2 m-filefor bysj2.fig
%      BYSJ2, by itself, creates a new BYSJ2 or raises the existing
%      singleton*.
%
%      H = BYSJ2 returns the handle to a new BYSJ2 or the handle to
%      the existing singleton*.
%
%      BYSJ2('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in BYSJ2.M with the given input arguments.
%
%      BYSJ2('Property'.'Value',...). creates anew BYSJ2 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before bysj2_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to bysj2_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE'sslit 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 bysj2

% Last Modified by GUIDE v2. 5 01-Jun- 2021. 10:08:35

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @bysj2_OpeningFcn, ...
                   'gui_OutputFcn',  @bysj2_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 bysj2 is made visible.
function bysj2_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 bysj2 (see VARARGIN)

% Choose default command line output for bysj2
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);
% UIWAIT makes bysj2 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
slidervalue=get(handles.slider1,'value');
set(handles.uipanel1,'userdata',slidervalue)
set(handles.edit1,'string',slidervalue*100)
a=get(handles.edit2,'value');
set(handles.edit2,'string',a);
b=get(handles.edit5,'value');
set(handles.edit5,'string',b);
circular_handle=findobj('tag'.'circular');
set(circular_handle,'userdata'.0.05)
body1;

% --- Outputs from this function are returned to the command line.
function varargout = bysj2_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;


% --- Executes when selected object is changed in uipanel1.
function uipanel1_SelectionChangeFcn(hObject, eventdata, handles)
% hObject    handle to the selected object in uipanel1 
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
body;

% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
% hObject    handle to slider1 (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

slidervalue=get(hObject,'value');
set(handles.uipanel1,'userdata',slidervalue)
set(handles.edit1,'string',slidervalue*100)
body1;

% --- Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider1 (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 edit1_Callback(hObject, eventdata, handles)
% hObject    handle to edit1 (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 edit1 as text
%        str2double(get(hObject,'String')) returns contents of edit1 as a double
current_str=get(hObject,'string');
current_val=str2double(current_str)/100;
if isnumeric(current_val)&length(current_val)= =1&current_val>=get(handles.slider1,'Min')&current_val<=get(handles.slider1,'Max'); % Verify that the input is numeric and within the wavelength rangeset(handles.slider1,'value',current_val);
    set(handles.uipanel1,'userdata',current_val);
    body1;
else
    msgbox('Please enter the correct wavelength (380-770)'.'Input error'.'warn');
end

% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (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 when user attempts to close figure1.
function figure1_CloseRequestFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: delete(hObject) closes the figure
selection=questdlg('Close the window? '.'Sure to close'.'Yes'.'No'.'Yes');
switch selection
    case 'Yes'
        delete(gcf)
    case'No'
        return
end


% --------------------------------------------------------------------
function Untitled_1_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)



function edit2_Callback(hObject, eventdata, handles)
% hObject    handle to edit2 (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 edit2 as text
%        str2double(get(hObject,'String')) returns contents of edit2 as a double
current_str=get(hObject,'string');
current_val=str2num(current_str);
if isnumeric(current_val)&length(current_val)&current_val>0; % Verify that the input is a non-zero number and is not emptyset(hObject,'value',current_val);   
    body1;
else
Copy the code

3. Operation results













Fourth, note

Version: 2014 a