📄 c6.m
字号:
function varargout = c6(varargin)
% C6 M-file for c6.fig
% C6, by itself, creates a new C6 or raises the existing
% singleton*.
%
% H = C6 returns the handle to a new C6 or the handle to
% the existing singleton*.
%
% C6('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in C6.M with the given input arguments.
%
% C6('Property','Value',...) creates a new C6 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before c6_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to c6_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 c6
% Last Modified by GUIDE v2.5 18-Jan-2006 11:48:23
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @c6_OpeningFcn, ...
'gui_OutputFcn', @c6_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin & isstr(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 c6 is made visible.
function c6_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 c6 (see VARARGIN)
% Choose default command line output for c6
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes c6 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = c6_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 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 Untitled_2_Callback(hObject, eventdata, handles)% hObject handle to Untitled_2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)data = getappdata(gcbf, 'metricdata');
%lam=500e-9;
%a=2e-3;
D=1;
ym=5*data.edit3*D/data.edit1;xs=ym;
n=101;ys=linspace(-ym,ym,n);
for i=1:n
r1=sqrt((ys(i)-data.edit1/2).^2+D^2);
r2=sqrt((ys(i)+data.edit1/2).^2+D^2);
phi=2*pi*(r1-r2)/data.edit3;
B(i,:)=4*cos(phi/2).^2;
end
N=255;
Br=(B/4.0)*N;
subplot(1,3,1)
%image(xs,ys,Br);
%colormap(gray(N));
%subplot(1,2,2)
plot(B,ys)% --------------------------------------------------------------------function Untitled_3_Callback(hObject, eventdata, handles)% hObject handle to Untitled_3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)%lam=500e-9;
%a=2e-3;
data = getappdata(gcbf, 'metricdata');
D=1;ymax=3*data.edit3*D/data.edit1;
Ny=51;
ys=linspace(-ymax,ymax,Ny);
NP=51;
yP=linspace(0,data.edit1,NP);
for i=1:Ny
SinPhi=ys(i)/D;
alpha=2*pi*yP*SinPhi/data.edit3;
SumCos=sum(cos(alpha));
SumSin=sum(sin(alpha));
B(i,:)=(SumCos^2+SumSin^2)/NP^2;
end
N=255;
Br=B/max(B)*N;
subplot(1,3,1);
%image(ymax,ys,Br);
%colormap(gray(N));
%subplot(1,2,2)
plot(B,ys)
% --------------------------------------------------------------------function Untitled_4_Callback(hObject, eventdata, handles)% hObject handle to Untitled_4 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)%lam=632.8e-9;N=2;
%a=2e-4;;d=5*a;
data = getappdata(gcbf, 'metricdata');
D=5;
ym=1.89*data.edit3*D/data.edit1;xs=ym;
n=1001;ys=linspace(-ym,ym,n);
for i=1:n
sinphi=ys(i)/D;
alpha=ys(i)/D;
alpha=pi*data.edit1*sinphi/data.edit3;
beta=pi*data.edit1*sinphi/data.edit3;
B(i,:)=(sin(alpha)./alpha).^2.*(sin(data.edit4*beta)./sin(beta)).^2;
B1=B/max(B);
end
NC=255;
Br=B/max(B)*NC;
subplot(1,3,1)
%image(xs,ys,Br);
%colormap(gray(NC));
%subplot(1,2,2)
plot(B1,ys)% --------------------------------------------------------------------function Untitled_5_Callback(hObject, eventdata, handles)% hObject handle to Untitled_5 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% --------------------------------------------------------------------function Untitled_6_Callback(hObject, eventdata, handles)% hObject handle to Untitled_6 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)
%lam=500e-9;
%a=2e-3;
data = getappdata(gcbf, 'metricdata');
D=1;
ym=5*data.edit3*D/data.edit1;xs=ym;
n=101;ys=linspace(-ym,ym,n);
for i=1:n
r1=sqrt((ys(i)-data.edit1/2).^2+D^2);
r2=sqrt((ys(i)+data.edit1/2).^2+D^2);
phi=2*pi*(r1-r2)/data.edit3;
B(i,:)=4*cos(phi/2).^2;
end
N=255;
Br=(B/4.0)*N;
subplot(1,3,1)
image(xs,ys,Br);
colormap(gray(N));
%subplot(1,2,2)
%plot(B,ys)% --------------------------------------------------------------------function Untitled_7_Callback(hObject, eventdata, handles)% hObject handle to Untitled_7 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)%lam=500e-9;
%a=2e-3;
D=1;
data = getappdata(gcbf, 'metricdata');
ymax=3*data.edit3*D/data.edit1;
Ny=51;
ys=linspace(-ymax,ymax,Ny);
NP=51;
yP=linspace(0,data.edit1,NP);
for i=1:Ny
SinPhi=ys(i)/D;
alpha=2*pi*yP*SinPhi/data.edit3;
SumCos=sum(cos(alpha));
SumSin=sum(sin(alpha));
B(i,:)=(SumCos^2+SumSin^2)/NP^2;
end
N=255;
Br=B/max(B)*N;
subplot(1,3,1);
image(ymax,ys,Br);
colormap(gray(N));
%subplot(1,2,2)
%plot(B,ys)% --------------------------------------------------------------------function Untitled_8_Callback(hObject, eventdata, handles)% hObject handle to Untitled_8 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)%lam=632.8e-9;N=2;
%a=2e-4;D=5;d=5*a;
data = getappdata(gcbf, 'metricdata');
D=5;
ym=1.89*data.edit3*D/data.edit1;xs=ym;
n=1001;ys=linspace(-ym,ym,n);
for i=1:n
sinphi=ys(i)/D;
alpha=ys(i)/D;
alpha=pi*data.edit1*sinphi/data.edit3;
beta=pi*data.edit2*sinphi/data.edit3;
B(i,:)=(sin(alpha)./alpha).^2.*(sin(data.edit4*beta)./sin(beta)).^2;
B1=B/max(B);
end
NC=255;
Br=B/max(B)*NC;
subplot(1,3,1)
image(xs,ys,Br);
colormap(gray(NC));
%subplot(1,2,2)
%plot(B1,ys)
% --------------------------------------------------------------------function Untitled_9_Callback(hObject, eventdata, handles)% hObject handle to Untitled_9 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% --------------------------------------------------------------------function Untitled_10_Callback(hObject, eventdata, handles)% hObject handle to Untitled_10 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)%lam=500e-9;
%a=2e-3;
data = getappdata(gcbf, 'metricdata');
D=1;
ym=5*data.edit3*D/data.edit1;xs=ym;
n=101;ys=linspace(-ym,ym,n);
for i=1:n
r1=sqrt((ys(i)-data.edit1/2).^2+D^2);
r2=sqrt((ys(i)+data.edit1/2).^2+D^2);
phi=2*pi*(r1-r2)/data.edit3;
B(i,:)=4*cos(phi/2).^2;
end
N=255;
Br=(B/4.0)*N;
subplot(1,3,1)
image(xs,ys,Br);
colormap(gray(N));
subplot(1,3,2)
plot(B,ys)% --------------------------------------------------------------------function Untitled_11_Callback(hObject, eventdata, handles)% hObject handle to Untitled_11 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)lam=500e-9;
a=2e-3;
data = getappdata(gcbf, 'metricdata');
D=1;
ymax=3*data.edit3*D/data.edit1;
Ny=51;
ys=linspace(-ymax,ymax,Ny);
NP=51;
yP=linspace(0,data.edit1,NP);
for i=1:Ny
SinPhi=ys(i)/D;
alpha=2*pi*yP*SinPhi/data.edit3;
SumCos=sum(cos(alpha));
SumSin=sum(sin(alpha));
B(i,:)=(SumCos^2+SumSin^2)/NP^2;
end
N=255;
Br=B/max(B)*N;
subplot(1,3,1);
image(ymax,ys,Br);
colormap(gray(N));
subplot(1,3,2)
plot(B,ys)% --------------------------------------------------------------------function Untitled_12_Callback(hObject, eventdata, handles)% hObject handle to Untitled_12 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)%lam=632.8e-9;N=2;
%a=2e-4;D=5;d=5*a;
data = getappdata(gcbf, 'metricdata');
D=5;
ym=1.89*data.edit3*D/data.edit1;xs=ym;
n=1001;ys=linspace(-ym,ym,n);
for i=1:n
sinphi=ys(i)/D;
alpha=ys(i)/D;
alpha=pi*data.edit1*sinphi/data.edit3;
beta=pi*data.edit2*sinphi/data.edit3;
B(i,:)=(sin(alpha)./alpha).^2.*(sin(data.edit4*beta)./sin(beta)).^2;
B1=B/max(B);
end
NC=255;
Br=B/max(B)*NC;
subplot(1,3,1)
image(xs,ys,Br);
colormap(gray(NC));
subplot(1,3,2)
plot(B1,ys)% --- 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 set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction 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 doublea = str2num(get(hObject, 'String'));
if isempty(a)
set(hObject, 'String', 0);
errordlg('Input must be a number','Error');
end
data = getappdata(gcbf, 'metricdata');
data.edit1= a;
setappdata(gcbf, 'metricdata', data);% --- 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 set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction 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 doubled = str2num(get(hObject, 'String'));
if isempty(d)
set(hObject, 'String', 0);
errordlg('Input must be a number','Error');
end
data = getappdata(gcbf, 'metricdata');
data.edit2= d;
setappdata(gcbf, 'metricdata', data);% --- 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 set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction 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 doubleBc = str2num(get(hObject, 'String'));
if isempty(Bc)
set(hObject, 'String', 0);
errordlg('Input must be a number','Error');
end
data = getappdata(gcbf, 'metricdata');
data.edit3= Bc;
setappdata(gcbf, 'metricdata', data);% --- 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 set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction 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 doubleN = str2num(get(hObject, 'String'));
if isempty(N)
set(hObject, 'String', 0);
errordlg('Input must be a number','Error');
end
data = getappdata(gcbf, 'metricdata');
data.edit4= N;
setappdata(gcbf, 'metricdata', data);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -