⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 poincare.m

📁 提供一个求解庞加莱映射的方法
💻 M
📖 第 1 页 / 共 2 页
字号:
function varargout = poincare(varargin)
% poincare Application M-file for poincare.fig
%    FIG = poincare launch poincare GUI.
%    poincare('callback_name', ...) invoke the named callback.

% Last Modified by GUIDE v2.5 03-Nov-2005 19:19:12
% Author: J.M. Roth, MIT Lincoln Laboratory, jroth@ll.mit.edu

% This script plots the polarization Stokes vectors (S1, S2, S3) on a Poincare
% sphere.
% Type "poincare" at the Matlab prompt and a graphical window should pop up.
% Enter an input data file in the GUI, then click "Plot".  You can also save
% the output graph to a .jpg file.
%
% The input data file format can be modified to your instrument's output.
% Currently the format is compatible with the ThorLabs PA-430 Polarimeter.
% This data file format conforms to that produced by the above polarimeter's
% data logger application, which is part of the "polar4.exe" software provided
% for this instrument.  This software is running on a Win95 machine 
% with a Keithley DAS-1700 PCI board controlling the polarimeter.

% This plot routine uses shading to indicate where on the 3-D surface the
% data lies.  That is, if the data is on the back-side of the sphere, then
% it should be shaded; otherwise it is not shaded.  The routine behaves in
% this manner in the figure window on the screen, however, unfortunately
% there is a bug regarding this shading algorithm if the figure is printed
% (directly to a printer) or if the figure is saved to a graphical file.
% Matlab suggested that this is due to a bug in the OpenGL graphics
% renderer.  They have confirmed this bug in both Matlab 7.1 and Matlab
% 7.2.  So far I have not found a suitable workaround.  Matlab suggested
% the following items below, which I did not find to correct the problem:
% 
% "1. Use the ZBUFFER renderer to display your figure.  You can change the 
% renderer by entering the following code at the MATLAB Command Prompt:
%
% set(gcf,'Renderer','Zbuffer');
%
% This code changes the renderer for the current figure; if you have 
% multiple figures open, you can make a figure current by maximizing it and 
% then maximizing the MATLAB Command Window.
%
% 2. Nudge the magenta circle's position off the face of the sphere.  It 
% appears that the OpenGL renderer treats the circle as if it is inside 
% the surface of the sphere.  We have corrected the improper shading by 
% moving the circle away from the sphere's surface.
%
% [THREAD ID: 1-2R3S71]",
% Zach Carwile, Application Support Engineer, Technical Support Department,
% The MathWorks, Inc., Phone: (508) 647-7000 option 5 
% 
% Another way I have found to get around this problem is to use a line instead
% of a dot to plot the data; however, this joins together all the data which
% can look disjointed.



if nargin == 0  % LAUNCH GUI
%    close all
    fig = openfig(mfilename,'reuse');

    % Generate a structure of handles to pass to callbacks, and store it.
    handles = guihandles(fig);
    guidata(fig, handles);

    if nargout > 0
        varargout{1} = fig;
    end
% Generate default filename using format: YYYY-MM-DD_HHMMSS
    cl = fix(clock);
savegraph_filename = strcat('fig_poincare_',num2str(cl(1)),'-',num2str(cl(2)),'-',num2str(cl(3)),'_',num2str(cl(4)),num2str(cl(5)),num2str(cl(6)));
    savegraph_filepath = strcat('/home/jroth/',savegraph_filename);
    set(handles.edit21,'string',savegraph_filename)  % write variable to edit21
    set(handles.edit22,'string',savegraph_filepath)   % filename including path

elseif ischar(varargin{1}) % INVOKE NAMED SUBFUNCTION OR CALLBACK

    try
        if (nargout)
            [varargout{1:nargout}] = feval(varargin{:}); % FEVAL switchyard
        else
            feval(varargin{:}); % FEVAL switchyard
        end
    catch
        disp(lasterr);
    end

end
end


%| ABOUT CALLBACKS:
%| GUIDE automatically appends subfunction prototypes to this file, and
%| sets objects' callback properties to call them through the FEVAL
%| switchyard above. This comment describes that mechanism.
%|
%| Each callback subfunction declaration has the following form:
%| <SUBFUNCTION_NAME>(H, EVENTDATA, HANDLES, VARARGIN)
%|
%| The subfunction name is composed using the object's Tag and the
%| callback type separated by '_', e.g. 'slider2_Callback',
%| 'figure1_CloseRequestFcn', 'axis1_ButtondownFcn'.
%|
%| H is the callback object's handle (obtained using GCBO).
%|
%| EVENTDATA is empty, but reserved for future use.
%|
%| HANDLES is a structure containing handles of components in GUI using
%| tags as fieldnames, e.g. handles.figure1, handles.slider2. This
%| structure is created at GUI startup using GUIHANDLES and stored in
%| the figure's application data using GUIDATA. A copy of the structure
%| is passed to each callback.  You can store additional information in
%| this structure at GUI startup, and you can change the structure
%| during callbacks.  Call guidata(h, handles) after changing your
%| copy to replace the stored original so that subsequent callbacks see
%| the updates. Type "help guihandles" and "help guidata" for more
%| information.
%|
%| VARARGIN contains any extra arguments you have passed to the
%| callback. Specify the extra arguments by editing the callback
%| property in the inspector. By default, GUIDE sets the property to:
%| <MFILENAME>('<SUBFUNCTION_NAME>', gcbo, [], guidata(gcbo))
%| Add any extra arguments after the last argument, before the final
%| closing parenthesis.


% --------------------------------------------------------------------
function varargout = pushbutton1_Callback(h, eventdata, handles, varargin)
format long
% Default input file
def_input_file = get(handles.edit12,'string');  % default input data filename plus path
% Specify input file
[filename1, pathname1]=uigetfile({'*.*','All files (*.*)'},'Import data [must conform to correct format]',def_input_file);
% opens dialog in present working directory (pwd)
myfile1=fullfile(pathname1, filename1);
handles.filename1 = filename1;  % filename only
handles.myfile1 = myfile1;  % filename plus path
set(handles.edit11,'string',...
    [handles.filename1])  % filename only
guidata(gcbo,handles) % store the changes
set(handles.edit12,'string',...
    [handles.myfile1])  % filename including path
guidata(gcbo,handles) % store the changes
end

% --------------------------------------------------------------------
% Specify output file name to save graph
function varargout = pushbutton2_Callback(h, eventdata, handles, varargin)
% Default output file
def_output_file = get(handles.edit22,'string');  % default input data filename plus path
% Do not include .jpg extension for now; added below in plotting function
[filename2, pathname2]=uiputfile({'*','JPEG files'},'Specify filename for plot [do not include .jpg extension]',def_output_file);
myfile2=fullfile(pathname2, filename2);
pathname2;
%     handles.filename3 = filename3;
%     set(handles.edit8,'string',...
%     [handles.filename3])
%     guidata(gcbo,handles) % store the changes

handles.filename2 = filename2;  % filename only
handles.myfile2 = myfile2;  % filename plus path
set(handles.edit21,'string',...
    [handles.filename2])  % filename only
set(handles.edit22,'string',...
    [handles.myfile2])  % filename including path
guidata(gcbo,handles) % store the changes
end

% --------------------------------------------------------------------
% Check box button to enable output file saving
% This is a boolean operation that toggles file save option
function varargout = checkbox1_Callback(h, eventdata, handles, varargin)
cur_save_val = get(handles.edit1,'string');  % get current value in edit1
if cur_save_val == 'N'
    set(handles.edit1,'string','Y')  % write variable to edit1
elseif cur_save_val == 'Y'
    set(handles.edit1,'string','N')  % write variable to edit1
end
% "Y" >> save file
% "N" = do not save file
guidata(gcbo,handles) % store the changes
end

% --------------------------------------------------------------------
% Exit button
function varargout = pushbutton4_Callback(h, eventdata, handles, varargin)
close;
end

% --------------------------------------------------------------------
% Run button
function varargout = pushbutton3_Callback(h, eventdata, handles, varargin)
format long

% Sample data taken using ThorLabs PA-430 Polarimeter
% Data file format conforms to output data file from polarimeter's data logger
% Polarimeter controlled by polar4.exe software on Win95 machine 
% using Keithley DAS-1700 PCI board
% retrieve filenames
input_filename = get(handles.edit11,'string');  % input data filename
input_file = get(handles.edit12,'string');  % input data filename plus path
savegraph_filename = get(handles.edit21,'string');  % output plot filename
savegraph_file = get(handles.edit22,'string');  % output plot filename plus path


% load data from file
M = csvread(input_file);
% Extract data from file
dat_t = M(:,1);  % time, units?
dat_0 = M(:,2);  % Stokes vector S0? ("power")
dat_1 = M(:,3);  % Stokes vector S1
dat_2 = M(:,4);  % Stokes vector S2
dat_3 = M(:,5);  % Stokes vector S3
dat_4 = M(:,6);  % DOP

% process data
%% Eliminate spurious Stokes vectors if |S|>1;
%% round off polarimeter errors to |1|
%% for ii = 1:length(dat_1)
%%     if abs(dat_1(ii))>1
%%         dat_1(ii) = round(dat_1(ii));
%%     end
%%     if abs(dat_2(ii))>1

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -