MATLAB 高斯光束传播轨迹的模拟

更新时间:2024-06-11 18:41:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

B1:高斯光束传播轨迹的模拟

设计任务:

作图表示高斯光束的传播轨迹

(1)基模高斯光束在自由空间的传播轨迹; (2)基模高斯光束经单透镜变换前后的传播轨迹; (3)基模高斯光束经调焦望远镜变换前后的传播轨迹。

function varargout = B1(varargin) % B1 M-file for B1.fig

% B1, by itself, creates a new B1 or raises the existing % singleton*. %

% H = B1 returns the handle to a new B1 or the handle to % the existing singleton*. %

% B1('CALLBACK',hObject,eventData,handles,...) calls the local

% function named CALLBACK in B1.M with the given input arguments. %

% B1('Property','Value',...) creates a new B1 or raises the

% existing singleton*. Starting from the left, property value pairs are % applied to the GUI before B1_OpeningFunction gets called. An

% unrecognized property name or invalid value makes property application % stop. All inputs are passed to B1_OpeningFcn via varargin. %

% *See GUI Options on GUIDE's Tools menu. Choose \% instance to run (singleton)\%

% See also: GUIDE, GUIDATA, GUIHANDLES

% Copyright 2002-2003 The MathWorks, Inc.

% Edit the above text to modify the response to help B1

% Last Modified by GUIDE v2.5 21-Oct-2010 17:52:32

% Begin initialization code - DO NOT EDIT gui_Singleton = 1;

gui_State = struct('gui_Name', mfilename, ...

'gui_Singleton', gui_Singleton, ...

'gui_OpeningFcn', @B1_OpeningFcn, ... 'gui_OutputFcn', @B1_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 B1 is made visible.

function B1_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 B1 (see VARARGIN)

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

% Update handles structure guidata(hObject, handles);

% UIWAIT makes B1 wait for user response (see UIRESUME) % uiwait(handles.figure1);

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

handles.W0=str2double(get(handles.editW0,'string')); handles.B=str2double(get(handles.editB,'string')); guidata(hObject,handles); Z=-100:100;

W=(handles.W0*10^4)*(sqrt(1+handles.B^2*(Z*10^6).^2./(pi^2*(handles.W0*10^4)^4))); plot(Z,W,'b',Z,-W,'b');

% --- Executes on button press in pushbutton2.

function pushbutton2_Callback(hObject, eventdata, handles) % hObject handle to pushbutton2 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

handles.W0=str2double(get(handles.editW0,'string')); handles.B=str2double(get(handles.editB,'string'))/1000; handles.Z=str2double(get(handles.editZ,'string'))*1000; handles.f=str2double(get(handles.editf,'string'))*10;

L=(handles.Z-handles.f)*handles.f^2/((handles.Z-handles.f)^2+pi^2*handles.W0^4/handles.B^2)+handles.f;

T1=-handles.Z:1:handles.Z;

Y1=handles.W0*sqrt(1+T1.^2*handles.B^2/(pi^2*handles.W0^4)); T2=handles.Z:1:(handles.Z+2*L);

W1=(handles.W0*handles.f/sqrt((handles.f-handles.Z)^2+pi^2*handles.W0^4/handles.B^2)); Y2=W1*sqrt(1+(T2-handles.Z-L).^2/(pi^2*W1^4/handles.B^2)); plot(T1,Y1,'b',T1,-Y1,'b',T2,Y2,'r',T2,-Y2,'r');

% --- Executes on button press in pushbutton3.

function pushbutton3_Callback(hObject, eventdata, handles) % hObject handle to pushbutton3 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

handles.W0=str2double(get(handles.editW0,'string')); handles.B=str2double(get(handles.editB,'string'))/1000; handles.f1=str2double(get(handles.editf1,'string'))*10; handles.Z=str2double(get(handles.editZ,'string'))*1000; handles.f2=str2double(get(handles.editf2,'string'))*10;

L=(handles.Z-handles.f1)*handles.f1^2/((handles.Z-handles.f1)^2+pi^2*handles.W0^4/handles.B^2)+handles.f1;

T1=-handles.Z:1:handles.Z;

Y1=handles.W0*sqrt(1+T1.^2*handles.B^2/(pi^2*handles.W0^4)); T2=handles.Z:1:(handles.Z+L+handles.f2);

W1=(handles.W0*handles.f1./sqrt((handles.f1-handles.Z)^2+pi^2*handles.W0^4./handles.B^2)); Y2=W1*sqrt(1+(T2-handles.Z-L).^2./(pi^2*W1^4/handles.B^2)); W2=W1*sqrt(1+handles.f2^2/(pi^2*W1^4/handles.B^2)); T3=(handles.Z+L+handles.f2):1:3*(handles.Z+L+handles.f2); Y3=W2;

plot(T1,Y1,'b',T1,-Y1,'b',T2,Y2,'r',T2,-Y2,'r',T3,Y3,'g',T3,-Y3,'g'); grid on;

function editW0_Callback(hObject, eventdata, handles) % hObject handle to editW0 (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 editW0 as text

% str2double(get(hObject,'String')) returns contents of editW0 as a double

% --- Executes during object creation, after setting all properties. function editW0_CreateFcn(hObject, eventdata, handles) % hObject handle to editW0 (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

set(hObject,'BackgroundColor','white'); else

set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end

function editB_Callback(hObject, eventdata, handles) % hObject handle to editB (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 editB as text

% str2double(get(hObject,'String')) returns contents of editB as a double

% --- Executes during object creation, after setting all properties. function editB_CreateFcn(hObject, eventdata, handles) % hObject handle to editB (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

set(hObject,'BackgroundColor','white'); else

set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end

function editZ_Callback(hObject, eventdata, handles) % hObject handle to editZ (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 editZ as text

% str2double(get(hObject,'String')) returns contents of editZ as a double

% --- Executes during object creation, after setting all properties. function editZ_CreateFcn(hObject, eventdata, handles) % hObject handle to editZ (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

set(hObject,'BackgroundColor','white'); else

set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end

function editf_Callback(hObject, eventdata, handles) % hObject handle to editf (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 editf as text

% str2double(get(hObject,'String')) returns contents of editf as a double

% --- Executes during object creation, after setting all properties. function editf_CreateFcn(hObject, eventdata, handles) % hObject handle to editf (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

set(hObject,'BackgroundColor','white'); else

set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end

function editf1_Callback(hObject, eventdata, handles) % hObject handle to editf1 (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 editf1 as text

% str2double(get(hObject,'String')) returns contents of editf1 as a double

% --- Executes during object creation, after setting all properties. function editf1_CreateFcn(hObject, eventdata, handles) % hObject handle to editf1 (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

set(hObject,'BackgroundColor','white'); else

set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end

function editf2_Callback(hObject, eventdata, handles) % hObject handle to editf2 (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 editf2 as text

% str2double(get(hObject,'String')) returns contents of editf2 as a double

% --- Executes during object creation, after setting all properties. function editf2_CreateFcn(hObject, eventdata, handles) % hObject handle to editf2 (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

set(hObject,'BackgroundColor','white'); else

set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end

% --- Executes on mouse press over axes background.

function axes1_ButtonDownFcn(hObject, eventdata, handles) % hObject handle to axes1 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

% --- Executes on button press in pushbutton4.

function pushbutton4_Callback(hObject, eventdata, handles) close(gcf)

% hObject handle to pushbutton4 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

% --- Executes on key press over pushbutton4 with no controls selected. function pushbutton4_KeyPressFcn(hObject, eventdata, handles) % hObject handle to pushbutton4 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

本文来源:https://www.bwwdw.com/article/1xr6.html

Top