matlab代做,FPGA代做,淘宝,专业代做MATLAB、FPGA博士/硕士/本科毕业设计、项目仿真、Coursework、Assignment
QQ: 1224848052
function varargout = untitled(varargin)
% UNTITLED M-file for untitled.fig
% UNTITLED, by itself, creates a new UNTITLED or raises the existing
% singleton*.
%
% H = UNTITLED returns the handle to a new UNTITLED or the handle to
% the existing singleton*.
%
% UNTITLED('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in UNTITLED.M with the given input arguments.
%
% UNTITLED('Property','Value',...) creates a new UNTITLED or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before untitled_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to untitled_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @untitled_OpeningFcn, ...
'gui_OutputFcn', @untitled_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 untitled is made visible.
function untitled_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 untitled (see VARARGIN)
%I=imread('yuanlitu.jpg','jpg');
%axes(handles.axes4);
%image(I);axis off
% Choose default command line output for untitled
axes(handles.axes1);
axis([-0.3,0.5,-5e-5,5e-5]); % 设置坐标轴范围
hold on %保护当前的设置
axes(handles.axes2);
set(gca,'color',[0.122,0.012,0.62]); %设置坐标面背景颜色
axis([-4e-5,4e-5,-5e-5,5e-5]); %设置坐标轴标度范围
hold on %保护当前的设置
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes untitled wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = untitled_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;
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
% --- 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
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
% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (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
function edit3_Callback(hObject, eventdata, handles)
% hObject handle to edit3 (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 edit3 as text
% str2double(get(hObject,'String')) returns contents of edit3 as a double
% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit3 (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
function edit4_Callback(hObject, eventdata, handles)
% hObject handle to edit4 (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 edit4 as text
% str2double(get(hObject,'String')) returns contents of edit4 as a double
% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit4 (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 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)
width=str2num(get(handles.edit1,'string'));
distance=str2num(get(handles.edit2,'string'));
e_number=str2num(get(handles.edit3,'string'));
U=str2num(get(handles.edit4,'string'));
delay_time=str2num(get(handles.edit5,'string'));
D=str2num(get(handles.edit6,'string'));
h=6.62559e-34 ; m=9.10908e-31 ;
e=1.6021e-19 ;
a=width*1e-6; b=distance*1e-6;
yy1=10*(a+(b/2));yy2=10*(-b/2);yy3=10*(-a-(b/2)-(2e-6));
rd=h/sqrt(2*m*e*U); %计算电子波长rd
A=(pi*a)/(rd*D);B=pi*(a+b)/(rd*D); %计算A和B
%a0=(e*U)/(m*0.08); %U=1000时,a0=2.1985e+15
%v0=((2*e*U)/m)^(1/2); %U=1000时,v0=1.8755e+7
a0=U/50;v0=U/10000;
axes(handles.axes1);
axis([-0.3,0.5,-5e-5,5e-5]);
rectangle('position',[-0.18,1e-6,0.004,2e-5],'FaceColor',[0,0,0]); % 负极上部分
rectangle('position',[-0.18,-1e-6-2e-5,0.004,2e-5],'FaceColor',[0,0,0]); % 负极下部分
rectangle('position',[-0.1,1e-6,0.004,2e-5],'FaceColor',[0,0,0]); % 正极上部分
rectangle('position',[-0.1,-1e-6-2e-5,0.004,2e-5],'FaceColor',[0,0,0]); % 正极下部分
rectangle('position',[0,yy1,0.004,2e-5],'FaceColor',[0,0,0]); % 光阑的上部分
rectangle('position',[0,yy2,0.004,10*b],'FaceColor',[0,0,0]); % 光阑的中间部分
rectangle('position',[0,yy3,0.004,2e-5],'FaceColor',[0,0,0]); % 光阑的下部分
rectangle('position',[D,-5e-5,0.007,1e-4],'FaceColor',[0,0,0]); % 观察屏
hold on
j=1;
while j<=e_number
axes(handles.axes1);
x1=-0.18;y1=0;
t=0;
M=rand;
if M<=0.5;
N=1;
else N=-1;
end
x=4e-5*(2*rand-1); %产生4e-5至-4e-5之间均匀分布的随机数赋给x
y=5e-5*(2*rand-1); %产生5e-5至-5e-5之间均匀分布的随机数赋给y
H=(((sin(A*y))^2)/(A*y)^2)*((cos(B*y))^2); %计算H
R=rand;
if H>=R %用分支结构选择符合条件的坐标点
hold on
p=plot(x1,y1,'.','EraseMode','xor','MarKerSize',14,'color','r');%定义入射为圆点
axis([-0.3,0.5,-5e-5,5e-5]);
while x1<=-0.1; % 在加速电场的传播情况
t=t+0.01;
x1=x1+(0.5*a0*(t^2));
set(p,'XData',x1,'YData',y1);
pause(delay_time);
end
t=0;
while x1<=0; %在狭缝前的传播情况
t=t+0.01;
x1=x1+v0*t;
y1=N*((a+b)*50)*(x1+0.1);
set(p,'XData',x1,'YData',y1);
pause(delay_time);
end
hold on
x1=0;y1=N*((a+b)*5);t=0;
while x1<=(D-0.006); % 在狭缝到屏的传播情况
t=t+0.01;
x1=x1+v0*t;
y1=((y-(N*((a+b)*5)))/D)*x1+N*((a+b)*5);
set(p,'XData',x1,'YData',y1);
pause(delay_time);
hold on
end
axes(handles.axes2);
set(gca,'color',[0.122,0.012,0.62]);
h_point=plot(x,y,'.w','EraseMode','none','markerSize',10);
axis([-4e-5,4e-5,-5e-5,5e-5]);
hold on
end
j=j+1;
pause(delay_time);
end
ym=2*rd*D/a;xs=ym;
Ny=10000
ys=linspace(-ym,ym,Ny);
for i=1:Ny
sinphi=ys(i)/D;
alpha=pi*a*sinphi/rd;
beta=pi*(a+b)*sinphi/rd;
I(i,:)=(sin(alpha)./alpha).^2.*(sin(2*beta)./sin(beta)).^2;
Io=I/max(I);
end
axes(handles.axes3);
set(gca,'color','w');
plot(Io,ys);
axis([0,1,-ym,ym]);
% --- 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)
axes(handles.axes1);
cla reset
width=str2num(get(handles.edit1,'string'));
distance=str2num(get(handles.edit2,'string'));
a=width*1e-6;
b=distance*1e-6;
D=0.25;
yy1=10*(a+(b/2));
yy2=10*(-b/2);
yy3=10*(-a-(b/2)-(2e-6));
axis([-0.3,0.5,-5e-5,5e-5]);
rectangle('position',[-0.18,1e-6,0.004,2e-5],'FaceColor',[0,0,0]); %负极上部分
rectangle('position',[-0.18,-1e-6-2e-5,0.004,2e-5],'FaceColor',[0,0,0]); % 负极下部分
rectangle('position',[-0.1,1e-6,0.004,2e-5],'FaceColor',[0,0,0]); % 正极上部分
rectangle('position',[-0.1,-1e-6-2e-5,0.004,2e-5],'FaceColor',[0,0,0]); % 正极下部分
rectangle('position',[0,yy1,0.004,2e-5],'FaceColor',[0,0,0]); %光阑的上部分
rectangle('position',[0,yy2,0.004,10*b],'FaceColor',[0,0,0]); % 光阑的中间部分
rectangle('position',[0,yy3,0.004,2e-5],'FaceColor',[0,0,0]); % 光阑的下部分
rectangle('position',[D,-5e-5,0.007,1e-4],'FaceColor',[0,0,0]); % 观察屏
hold on
axes(handles.axes2);
cla reset
set(gca,'color',[0.122,0.012,0.62]);
axis([-4e-5,4e-5,-5e-5,5e-5]);
axes(handles.axes3);
cla reset
% --- 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)
close all
% --- Executes during object creation, after setting all properties.
function axes1_CreateFcn(hObject, eventdata, handles)
% hObject handle to axes1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: place code in OpeningFcn to populate axes1
function edit5_Callback(hObject, eventdata, handles)
% hObject handle to edit5 (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 edit5 as text
% str2double(get(hObject,'String')) returns contents of edit5 as a double
function edit6_Callback(hObject, eventdata, handles)
% hObject handle to edit6 (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 edit6 as text
% str2double(get(hObject,'String')) returns contents of edit6 as a double
% --- Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit6 (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