光学基于matlab GUI模拟波动光光学系统含Matlab源码 1064期

Posted 紫极神光(Q1564658423)

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了光学基于matlab GUI模拟波动光光学系统含Matlab源码 1064期相关的知识,希望对你有一定的参考价值。

一、简介

基于matlab GUI模拟波动光光学系统

二、源代码

%波动光学典型实验的MATLAB仿真
function varargout = bysj2(varargin)
% BYSJ2 M-file for 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 a new 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');%确认输入为数字,且在波长范围内
    set(handles.slider1,'value',current_val);
    set(handles.uipanel1,'userdata',current_val);
    body1;
else
    msgbox('请输入正确波长(380-770)','输入错误','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('关闭窗口?','确定关闭','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;%确认输入为非零数字,且非空
    set(hObject,'value',current_val);   
    body1;
else

三、运行结果

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

四、备注

版本:2014a

以上是关于光学基于matlab GUI模拟波动光光学系统含Matlab源码 1064期的主要内容,如果未能解决你的问题,请参考以下文章

matlab设计GUI

光学基于matlab GUI矩阵法和等效界面法光学薄膜对反射率影响含Matlab源码 2102期

光学基于matlab GUI矩阵法和等效界面法光学薄膜对反射率影响含Matlab源码 2102期

光学基于matlab GUI双孔干涉含Matlab源码 2119期

光学基于matlab GUI双孔干涉含Matlab源码 2119期

光学基于matlab GUI光栅条纹投影生成含Matlab源码 2118期