Code covered by the BSD License  

Highlights from
spec file reader

image thumbnail
from spec file reader by Zhang Jiang
Monitor, read, save scans from SPEC files and calculate true reflectivity.

truerefplot(varargin)
function truerefplot(varargin)
% TRUEREFPLOT Called by trueref to plot data
%
% Copyright 2004, Zhang Jiang

hFigTrueref = findall(0,'Tag','trueref_Fig');
hAxes = findall(hFigTrueref,'Tag','trueref_Axes');
if isappdata(hFigTrueref,'data')
    data = getappdata(hFigTrueref,'data');
else
    return;
end
% --- determine which curve to plot: all, ref, pos or neg
if nargin == 0
    plot_str = 'All';
else
    plot_str = varargin{1};
end
cla(hAxes);
% --- plot
switch plot_str
    case 'All'
        % --- plot reflecitivity
        if ~isempty(data.ref)
            hLineRef = [];
            for iLine = 1:length(data.ref)
                hLineRef(iLine) = line('Parent',hAxes,...
                    'XData',data.ref{iLine}(:,1),...
                    'YData',data.ref{iLine}(:,2),...
                    'Tag',['reflectivity',num2str(iLine)]);
                setappdata(hLineRef(iLine),'ydataError',data.ref{iLine}(:,3));
            end
            set(hLineRef,...
                'Color','k',...
                'LineStyle','-',...
                'Marker','o',...
                'MarkerSize',3,...
                'MarkerFaceColor','m');
        end
        % --- plot positive longitudinal diffuse
        if ~isempty(data.pos)
            hLinePos = [];
            for iLine = 1:length(data.pos)
                hLinePos(iLine) = line('Parent',hAxes,...
                    'XData',data.pos{iLine}(:,1),...
                    'YData',data.pos{iLine}(:,2),...
                    'Tag',['positiveLongDiffuse',num2str(iLine)]);
                setappdata(hLinePos(iLine),'ydataError',data.pos{iLine}(:,3));
            end
            set(hLinePos,...
                'Color','b',...
                'LineStyle','-',...
                'Marker','o',...
                'MarkerSize',3,...
                'MarkerFaceColor','m');
        end
        % --- plot negative longitudinal diffuse
        if ~isempty(data.neg)
            hLineNeg = [];
            for iLine = 1:length(data.neg)
                hLineNeg(iLine) = line('Parent',hAxes,...
                    'XData',data.neg{iLine}(:,1),...
                    'YData',data.neg{iLine}(:,2),...
                    'Tag',['negativeLongDiffuse',num2str(iLine)]);
                setappdata(hLineNeg(iLine),'ydataError',data.neg{iLine}(:,3));
            end
            set(hLineNeg,...
                'Color','g',...
                'LineStyle','-',...
                'Marker','o',...
                'MarkerSize',3,...
                'MarkerFaceColor','m');
        end
    case 'Ref'
        % --- plot reflecitivity
        if ~isempty(data.ref)
            hLineRef = [];
            for iLine = 1:length(data.ref)
                hLineRef(iLine) = line('Parent',hAxes,...
                    'XData',data.ref{iLine}(:,1),...
                    'YData',data.ref{iLine}(:,2),...
                    'Tag',['reflectivity',num2str(iLine)]);
                setappdata(hLineRef(iLine),'ydataError',data.ref{iLine}(:,3));
            end
            set(hLineRef,...
                'Color','k',...
                'LineStyle','-',...
                'Marker','o',...
                'MarkerSize',3,...
                'MarkerFaceColor','m');
        end
    case 'Pos'
        % --- plot positive longitudinal diffuse
        if ~isempty(data.pos)
            hLinePos = [];
            for iLine = 1:length(data.pos)
                hLinePos(iLine) = line('Parent',hAxes,...
                    'XData',data.pos{iLine}(:,1),...
                    'YData',data.pos{iLine}(:,2),...
                    'Tag',['positiveLongDiffuse',num2str(iLine)]);
                setappdata(hLinePos(iLine),'ydataError',data.pos{iLine}(:,3));
            end
            set(hLinePos,...
                'Color','b',...
                'LineStyle','-',...
                'Marker','o',...
                'MarkerSize',3,...
                'MarkerFaceColor','m');
        end
    case 'Neg'
        % --- plot negative longitudinal diffuse
        if ~isempty(data.neg)
            hLineNeg = [];
            for iLine = 1:length(data.neg)
                hLineNeg(iLine) = line('Parent',hAxes,...
                    'XData',data.neg{iLine}(:,1),...
                    'YData',data.neg{iLine}(:,2),...
                    'Tag',['negativeLongDiffuse',num2str(iLine)]);
                setappdata(hLineNeg(iLine),'ydataError',data.neg{iLine}(:,3));
            end
            set(hLineNeg,...
                'Color','g',...
                'LineStyle','-',...
                'Marker','o',...
                'MarkerSize',3,...
                'MarkerFaceColor','m');
        end
end
resettoolbar(hFigTrueref);
curvelegend(hFigTrueref);

Contact us at files@mathworks.com