text:
%% PTdispSetupInfo

% ----------------------------------------------------------------------------------
% "THE BEER-WARE LICENSE" (Revision 42):
% <brian.white@queensu.ca> wrote this file. As long as you retain this notice you
% can do whatever you want with this stuff. If we meet some day, and you think
% this stuff is worth it, you can buy me a beer in return. -Brian White
% ----------------------------------------------------------------------------------

if ~isempty(fnameMaster)

PTdisp=figure(5);
screensz = get(0,'ScreenSize');
set(PTdisp, 'units','normalized','outerposition',[.1 .1 .75 .8])
PTdisp.NumberTitle='on';
PTdisp.Name= ['PIDtoolbox (' PtbVersion ') -  Setup Info'];
set(PTdisp,'color',bgcolor)

columnWidth=55*round(screensz_multiplier*prop_max_screen);

TooltipString_FileNumDispA=['List of files available. Click to view setup info for each'];
posInfo.FileNumDispA=[.22 .95 .1 .04];
posInfo.FileNumDispB=[.72 .95 .1 .04];
posInfo.checkboxDIFF=[.04 .96 .1 .04];

guiHandlesInfo.FileNumDispA = uicontrol(PTdisp,'Style','popupmenu','string',[fnameMaster],...
    'fontsize',fontsz, 'units','normalized','outerposition', [posInfo.FileNumDispA],'callback','@selection; PTdispSetupInfo;');
guiHandlesInfo.FileNumDispA.Value=1;
if Nfiles > 1
    guiHandlesInfo.FileNumDispB = uicontrol(PTdisp,'Style','popupmenu','string',[fnameMaster],...
        'fontsize',fontsz, 'units','normalized','outerposition', [posInfo.FileNumDispB],'callback','@selection; PTdispSetupInfo;');
    guiHandlesInfo.FileNumDispB.Value=2;
end

guiHandlesInfo.checkboxDIFF =uicontrol(PTdisp,'Style','checkbox','String','Show Differences Only','fontsize',fontsz,'TooltipString', [''],...
    'units','normalized','BackgroundColor',bgcolor,'outerposition',[posInfo.checkboxDIFF],'callback', 'PTdispSetupInfo;');

else
     warndlg('Please select file(s)');
end

% functions
function selection(src,event)
    val = c.Value;
    str = c.String;
    str{val};
   % disp(['Selection: ' str{val}]);
end

repo: PIDtoolbox


text:
function C = addlongerror(C,err,exponent)
%ADDLONGERROR Add error to long number
%
%  C = addlongerror(A,err,exponent)
%
%Error term of C is updated by err. Third argument optional, default 0.
%If exponent is specified, error term is updated by err*10^exponent
%
%Input C, err and exponent may be column vectors
%

% written  12/30/98     S.M. Rump
% modfied  02/09/00     S.M. Rump  rounding unchanged after use
% modified 04/04/04     S.M. Rump  set round to nearest for safety
% modified 04/06/05     S.M. Rump  rounding unchanged
% modified 11/20/05     S.M. Rump  fast check for rounding to nearest
% modified 01/29/10     S.M. Rump  only warning if no interval arithmetic
% modified 08/26/12     S.M. Rump  global variables removed
%

  INTLAB_LONG_BETA = getappdata(0,'INTLAB_LONG_BETA');
  INTLAB_LONG_ERROR = getappdata(0,'INTLAB_LONG_ERROR');

  if ~INTLAB_LONG_ERROR
    warning('long arithmetic changed to interval arithmetic, see longinit')
    INTLAB_LONG_ERROR = 1;
  end

  if any( err<0 )
    error('negative error specified in addlongerror')
  end

  e = 1e-30;
  if 1+e==1-e                           % fast check for rounding to nearest
    rndold = 0;
  else
    rndold = getround;
    setround(0)
  end

  if nargin==3
    setround(1)
    % 10^exponent = beta^(Ernd+Efrac)
    E = exponent / log10(INTLAB_LONG_BETA);
    Ernd = round(E);
    Efrac = E - Ernd;
    err = err .* INTLAB_LONG_BETA.^Efrac;
    setround(0)                         % set rounding to nearest
  else
    Ernd = 0;
  end
  C.error = errorupdate( 1 , C.error , 0  , 1 , err , Ernd );
  C.error = errornormalize(C.error);

  C = normalize(C);

  setround(rndold)

repo: OpenMAS


text:
function plan = read_pinnacle_plan_trial(filename,trialname)
%
%	plan = read_pinnacle_plan_trial(filename,trialname)
%	read_pinnacle_plan_trial(filename) to list all trials

fid = fopen(filename,'r');
if fid < 0
	fprintf('Cannot open file: %s.\n',filename);
	return;
end

lineno = 0;
lastlineistrial = 0;
trialno = 0;
plan = [];

% Scan the whole file for all available trials
while 1
	tl = fgetl(fid);
	lineno = lineno+1;

	if feof(fid)
		break;
	end

	if length(tl) >= 10 && strcmp(tl(1:10),'  Name = "') == 1 && lastlineistrial == 1
		outl = strsplit_cerr('=',tl);
		tname = ddeblank(outl{2});
		tname = tname(1:end-2);
		tname = tname(2:end);
		trialnames{trialno,1} = tname;
		%triallines(trialno) = lineno-1;
        triallines(trialno) = trialLineNo;
	end

% 	if strcmp(tl,'Trial ={') == 1
% 		lastlineistrial = 1;
% 		trialno = trialno + 1;
% 	else
% 		lastlineistrial = 0;
% 	end
	if strcmp(tl,'Trial ={') == 1
		lastlineistrial = 1;
		trialno = trialno + 1;
        trialLineNo = lineno - 1;
    elseif strcmp(tl,'};') == 1
		lastlineistrial = 0;
	end

end

if ~exist('trialname','var')
	if length(trialnames) > 1
		disp('Trial names');
		trialnames
		return;
	else
		trialname = trialnames{1};
		fprintf('Trail name = %s\n',trialname);
	end
end

if ~exist('triallines','var')
    disp('Trail is not found');
    fclose(fid);
    return;
end

% find the trial
found = 0;
for k = 1:length(triallines)
	if strcmp(trialnames{k},trialname)
		found = 1;
		break;
	end
end

if found == 0
	disp('Trail is not found');
	fclose(fid);
	return;
end

fclose(fid);

fid = fopen(filename,'r');
lineno = 0;
while lineno < triallines(k)-1
	fgetl(fid);
	lineno = lineno + 1;
end

% Read the whole trial into the MATLAB structure
[planname,plan] = read_1_field_pinnacle(fid);

fclose(fid);

return;

author: cerr

repo: CERR

save_path: github-repos/MATLAB/cerr-CERR


text:
function autoShowSyn1(varargin)
% This function is used to provde synthetic data for a certain date (mm/dd/yyyy).
% two digits for QA band
%
% Specific parameters
% ------------------------
%   'InDir'     Directory of CCDC change detection results.
%                        Default is the path to current folder.
%   'OutDir'    Directory of the model output.  Default is the
%                        same as InputDirectory.
%   'Year'               Year.
%   'Month'              Month.
%   'Day'                Day.
%   'DOY'                Day of year.

% Examples:
% ------------------------
% autoShowSyn1('Year',2010,'Month',7,'Day',1)
% will give the synthetic data at July 1,2010.
%
% autoShowSyn1('Year',2010,'DOY',200)
% will give the synthetic data at 200th day,2010.
%

 %% get parameters from inputs
% where the all CCDC change detection results are
dir_cur = pwd;
% where the output files are
dir_out = '';
p = inputParser;
p.FunctionName = 'paras';

addParameter(p,'InDir',dir_cur);
addParameter(p,'OutDir',dir_out);
addParameter(p,'Year',0);
addParameter(p,'Month',0);
addParameter(p,'Day',0);
addParameter(p,'DOY',0);

parse(p,varargin{:});
dir_cur = p.Results.InDir;
dir_out = p.Results.OutDir;

yy=p.Results.Year;
mm=p.Results.Month;
dd=p.Results.Day;
doy=p.Results.DOY;
if isempty(dir_out)
    dir_out = dir_cur;
end

if yy>0
    if mm>0&&dd>0 % using yyyy/mm/dd
        % converted to julian date
        j_date=datenum(yy,mm,dd);
        j0_date=datenum(yy,1,0);
        doy = j_date-j0_date;
        % date for show i.e. 19990815
        %s_date=yy*10000+mm*100+dd;
        s_date = yy*1000 + doy;
    elseif doy>0 % using yyyy DOY
        j_date = datenum(yy,1,0) + doy;
        s_date = yy*1000 + doy;
    end
end
% v_input = ccdc_Input(dir_cur);

% 1. inputs: the time for predicted synthetic data
% yy=2000;
% mm=12;
% dd = 1;
% OR
% yy=2000;
% doy=120;

% nbands = v_input.nbands - 1;% number of bands in the image
% ncoefs = v_input.num_c;% number of coefficients
%
% % dimension and projection of the image
% % cd(v_input.l_dir);
% nrows = v_input.ijdim(1);
% ncols = v_input.ijdim(2);
% jiDim = [ncols,nrows];
% jiUL = v_input.jiul;
% res = v_input.resolu;
% zc = v_input.zc;

% get num of total folders start with "L"
imf=dir(fullfile(dir_cur,'L*')); % folder names
% filter for Landsat folders
imf = regexpi({imf.name}, 'L(T5|T4|E7|C8|ND)(\w*)', 'match');
imf = [imf{:}];
imf = vertcat(imf{:});
% sort according to yeardoy
yeardoy = str2num(imf(:, 10:16));
[~, sort_order] = sort(yeardoy);
imf = imf(sort_order, :);
% name of the first stacked image
filename = dir(fullfile(dir_cur,imf(1,:),'L*MTLstack'));
% read in dimension and zone number of the data
[jiDim,jiul,resolu,zc] = envihdrread(fullfile(dir_cur,imf(1,:),filename.name));

n_syn = ['LS',imf(1,4:9),num2str(s_date)];

nbands = 8; %original band amounts
nbands = nbands - 1; % show change for all the bands except fmask

ncoefs = 8; %max num of coefficients
nrows = jiDim(2);
ncols = jiDim(1);

% produce synthetic data (1, 2, 3, 4, 5, 7, and QA)
SR = -9999*ones(nrows,ncols,nbands,'int16'); % 1. change here for excluding thermal

% make Predict folder for storing predict images
%n_pre = v_input.name_pre;%'PredictAll';
n_pre = 'PredictAll';

if isempty(dir(fullfile(dir_cur,n_pre)))
    mkdir(fullfile(dir_cur,n_pre));
end

% folder saved everything
%n_rst = v_input.name_rst;
n_rst = 'TSFitMap';
%cd(n_rst);% TSFitMap

imf=dir(fullfile(dir_cur,n_rst,'record_change*')); % folder names
num_line = size(imf,1);

%%
for line = 1:num_line
    %fprintf('Processing %.2f percent\r',100*(line/num_line));
    load(fullfile(dir_cur,n_rst,imf(line).name));

    % postions & coefficients
    pos = [rec_cg.pos];
    % continue if there is no model available
    l_pos = length(pos);
    if l_pos == 0
        continue;
    end
    % get coefficients matrix
    coefs = [rec_cg.coefs];
    % reshape coefs
    coefs = reshape(coefs,nbands*ncoefs,l_pos);
    % get category matrix
    category = [rec_cg.category];
    % take the first digit (number of coefficients)
    category = category - 10*floor(category/10);

    % model start, end, & break time for prediction
    model_start = [rec_cg.t_start];
    model_end = [rec_cg.t_end];
    model_break = [rec_cg.t_break];
    % model on the right
    ids_right = model_start > j_date;
    % model on the left
    ids_left = (model_end < j_date & model_break == 0)|(model_break <= j_date & model_break > 0);
    % id within model interval
    ids_middle = model_start <= j_date & ((model_end >= j_date & model_break == 0) | (model_break > j_date & model_break > 0));

    % position for model in the middle
    pos_middle = pos(ids_middle);
    % coefficients for model in the middle
    coefs_middle = coefs(:,ids_middle);
    % category for model in the middle
    category_middle = category(ids_middle);

    % positions for the nearest model on the right
    pos_right = pos(ids_right);
    [pos_near_right,ids_near_right] = unique(pos_right,'first');
    % coefficients for the nearest model on the right
    coefs_right = coefs(:,ids_right);
    coefs_near_right = coefs_right(:,ids_near_right);
    % category for the nearest model on the right
    category_right = category(ids_right);
    category_near_right = category_right(ids_near_right);

    % postions for the nearest model on the left
    pos_left = pos(ids_left);
    [pos_near_left,ids_near_left] = unique(pos_left,'last');
    % coefficients for the nearest model on the left
    coefs_left = coefs(:,ids_left);
    coefs_near_left = coefs_left(:,ids_near_left);
    % category for the nearest model on the left
    category_left = category(ids_left);
    category_near_left = category_left(ids_near_left);

    % pass if there is no nearest model on the left
    l_pos=length(pos_near_left);
    if l_pos > 0
        % providing predictions
        for i=1:l_pos
            [I,J]=ind2sub(jiDim,pos_near_left(i));
            for j_b=1:nbands-1 % excluding thermal band
                SR(J,I,j_b)=autoTSPred(j_date,coefs_near_left(((j_b-1)*ncoefs+1):j_b*ncoefs,i));
            end
            % QA band
            SR(J,I,end) = 20 + category_near_left(i); % model forward predicted values
        end
    end

    % pass if there is no nearest model on the right
    l_pos=length(pos_near_right);
    if l_pos > 0
        % providing predictions
        for i=1:l_pos
            [I,J]=ind2sub(jiDim,pos_near_right(i));
            for j_b=1:nbands-1 % excluding thermal band
                SR(J,I,j_b)=autoTSPred(j_date,coefs_near_right(((j_b-1)*ncoefs+1):j_b*ncoefs,i));
            end
            % QA band
            SR(J,I,end) = 10 + category_near_right(i); % model backward predicted values
        end
    end

    % pass if there is no nearest model in the middle
    l_pos=length(pos_middle);
    if l_pos > 0
        % providing estimations
        for i=1:l_pos
            [I,J]=ind2sub(jiDim,pos_middle(i));
            for j_b=1:nbands-1 % excluding thermal band
                SR(J,I,j_b)=autoTSPred(j_date,coefs_middle(((j_b-1)*ncoefs+1):j_b*ncoefs,i));
            end
            % QA band
            SR(J,I,end) = 0 + category_middle(i); % model estimated values
        end
    end
end

n_bands = {'Band 1','Band 2','Band 3','Band 4','Band 5','Band 7','QA'};
% n_bands = 1:7;
% write ENVI files
ARD_enviwrite_bands_n(fullfile(dir_out,n_pre,n_syn),SR,'int16','bip',n_bands,dir_cur,dir_out);
end

author: GERSL

repo: CCDC

save_path: github-repos/MATLAB/GERSL-CCDC


text:
function polygon_properties_test07 ( )

%*****************************************************************************80
%
%% POLYGON_PROPERTIES_TEST07 tests POLYGON_EXPAND;
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    07 May 2014
%
%  Author:
%
%    John Burkardt
%
  n = 4;
  v = [ ...
    1.0, 1.0; ...
    5.0, 1.0; ...
    2.0, 4.0; ...
    1.0, 3.0 ]';

  fprintf ( 1, '\n' );
  fprintf ( 1, 'POLYGON_PROPERTIES_TEST07\n' );
  fprintf ( 1, '  For a polygon:\n' );
  fprintf ( 1, '  POLYGON_EXPAND "expands" it by an amount H.\n' );

  h = 0.5;

  r8mat_transpose_print ( 2, n, v, '  The polygon vertices:' );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  The expansion amount H = %g\n', h );

  w = polygon_expand ( n, v, h );

  r8mat_transpose_print ( 2, n, w, '  The expanded polygon:' );

  return
end

author: johannesgerer

repo: jburkardt-m


text:
function obj = setHessianPattern(obj, hes_sp, sp_form)
    % This function configure the sparsity pattern of the Hessian
    % of the function
    %
    % The form of given sparsity pattern is determined by the input
    % argument 'sp_form'. It can be one of the followings:
    %  'MatrixForm': the sparsity pattern is given as a matrix
    %  (dense or sparse). In this case we extract the row and column
    %  indices of non-zero elements from this matrix
    %  'Indexform': the sparsity pattern is directly given as
    %  vectors row and column indices of non-zero entries
    %
    % @note In MATLAB's sparse matrix, the values of same set of
    % row and column indices are added together. For example,
    % sparse([1;1],[1;1],[1,2]) will results in a sparse matrix
    % with 1+2 = 3 at entry (1,1).
    %
    % Parameters:
    %  hes_sp: a matrix array consists of sparsity pattern of Hessian
    %  of each element of the function @type cell
    %  sp_form: the type of given sparsity pattern. @type char

    % default form
    if nargin < 3
        sp_form = 'MatrixForm';
    end

    dimDeps = sum([obj.DepVariables.Dimension]);

    if isempty(hes_sp)
        obj.Type = NlpFunction.LINEAR;
        obj.HessPattern.Rows = [];
        obj.HessPattern.Cols = [];
    else

        switch sp_form
            case 'MatrixForm'

                [m, n, n_mat] = size(hes_sp);

                assert(n_mat == obj.Dimension && m==dimDeps && n==dimDeps,...
                    'NlpFunction:wrongDimension',...
                    ['The size of the Hessian matrix is incorrect.\n',...
                    'It must be a %d x %d x %d matrix.\n'], ...
                    dimDeps, dimDeps, obj.Dimension);

                % check the dimension
                sp_rows = cell(n_mat,1);
                sp_cols = cell(n_mat,1);
                for i=1:n_mat
                    [sp_rows{i}, sp_cols{i}] = find(hes_sp(:,:,i));
                end
                obj.HessPattern.Rows = vertcat(sp_rows{:});
                obj.HessPattern.Cols = vertcat(sp_cols{:});

            case 'IndexForm'

                % check if the maximum index exceeds the size of the
                % function or dependent variabbles
                m = max(hes_sp(:,1)); % the maximum row index
                n = max(hes_sp(:,2)); % the maximum column index

                assert(m <= dimDeps && n <= dimDeps,...
                    'NlpFunction:wrongDimension',...
                    'The size of the Hessian matrix is incorrect.\n');

                obj.HessPattern.Rows = hes_sp(:,1);
                obj.HessPattern.Cols = hes_sp(:,2);

            otherwise
                error('Unspecified form of the sparsity pattern.\n');
        end
    end
    obj.nnzHess = length(obj.HessPattern.Rows);
end

author: ayonga

repo: frost-dev

save_path: github-repos/MATLAB/ayonga-frost-dev


text:
function s_filt = elim_sub_cardiac(old_data, up)
%% Filter pre-processed signal to remove frequencies below cardiac freqs

fs = old_data.fs;
s = old_data;

%% Eliminate nans
s.v(isnan(s.v)) = mean(s.v(~isnan(s.v)));

%% Downsample
d_s = downsample_data(s, up);

%% Make filter
flag  = 'scale';        % Sampling Flag
[N,Wn,BETA,TYPE] = kaiserord([up.paramSet.elim_sub_cardiac.Fstop up.paramSet.elim_sub_cardiac.Fpass]/(d_s.fs/2), [1 0], [up.paramSet.elim_sub_cardiac.Dstop up.paramSet.elim_sub_cardiac.Dpass]);
b  = fir1(N, Wn, TYPE, kaiser(N+1, BETA), flag);   % Calculate the coefficients using the FIR1 function.
AMfilter = dfilt.dffir(b);

%% Check frequency response
% Gives a -3 dB cutoff at ? Hz, using:
% freqz(AMfilter.Numerator)
% norm_cutoff_freq = 0.04;    % insert freq here from plot
% cutoff_freq = norm_cutoff_freq*(d_s.fs/2);

temp_filt = filtfilt(AMfilter.numerator, 1, d_s.v);

%% Resample
s_filt_rs.v = interp1(d_s.t, temp_filt, s.t);
s_filt.v = s.v(:)-s_filt_rs.v(:);
s_filt.t = s.t;
s_filt.fs = s.fs;
end

author: peterhcharlton

repo: RRest


text:
classdef ColorSelector < wt.abstract.BaseWidget &...
        wt.mixin.Enableable & wt.mixin.FontStyled & wt.mixin.Tooltipable & ...
        wt.mixin.FieldColorable
    % A color selection control with browse button

    % Copyright 2020-2021 The MathWorks Inc.

    %% Public properties
    properties (AbortSet)

        % The current value shown
        Value (1,3) double {wt.validators.mustBeBetweenZeroAndOne} = [0 1 0]

    end %properties

    % These properties do not trigger the update method
    properties (AbortSet, UsedInUpdate = false)

        % Indicates whether to show the edit field
        ShowEditField (1,1) matlab.lang.OnOffSwitchState = true

    end %properties

    %% Events
    events (HasCallbackProperty, NotifyAccess = protected)

        % Triggered on value changed, has companion callback
        ValueChanged

    end %events

    %% Internal Properties
    properties ( Transient, NonCopyable, ...
            Access = {?wt.abstract.BaseWidget, ?wt.test.BaseWidgetTest} )

        % Button
        ButtonControl (1,1) matlab.ui.control.Button

        % Edit control
        EditControl (1,1) matlab.ui.control.EditField

    end %properties

    %% Protected methods
    methods (Access = protected)

        function setup(obj)

            % Call superclass setup first to establish the grid
            obj.setup@wt.abstract.BaseWidget();

            % Set default size
            obj.Position(3:4) = [100 25];

            % Configure Grid
            obj.Grid.ColumnWidth = {'1x',25};
            obj.Grid.RowHeight = {'1x'};

            % Create the standard edit control
            obj.EditControl = matlab.ui.control.EditField(...
                "Parent",obj.Grid,...
                "ValueChangedFcn",@(h,e)obj.onTextChanged(e));

            % Create Button
            obj.ButtonControl = matlab.ui.control.Button(...
                "Parent",obj.Grid,...
                "Text","",...
                "ButtonPushedFcn",@(h,e)obj.onButtonPushed(e));

            % Update the internal component lists
            obj.FontStyledComponents = [obj.EditControl];
            obj.FieldColorableComponents = [obj.EditControl];
            obj.EnableableComponents = [obj.EditControl, obj.ButtonControl];
            obj.TooltipableComponents = [obj.EditControl, obj.ButtonControl];

        end %function

        function update(obj)

            % Update the edit control text
            obj.EditControl.Value = mat2str(obj.Value,2);

            % Update the button color
            obj.ButtonControl.BackgroundColor = obj.Value;

        end %function

        function updateFieldVisibility(obj)

            % Is history being shown? If so, update history and items
            if obj.ShowEditField
                % Showing edit field

                if isempty(obj.EditControl.Parent)
                    obj.ButtonControl.Layout.Column = 2;
                    obj.EditControl.Parent = obj.Grid;
                    obj.EditControl.Layout.Column = 1;
                    obj.EditControl.Layout.Row = 1;
                end

            else
                % Hiding edit field

                if ~isempty(obj.EditControl.Parent)
                    obj.EditControl.Parent = [];
                    obj.ButtonControl.Layout.Column = [1 2];
                end

            end %if

        end %function

        function onButtonPushed(obj,~)
            % Triggered on button pushed

            % Get prior value
            oldValue = obj.Value;

            % Prompt for a new color
            newColor = uisetcolor(oldValue);

            % Did user make a choice or cancel?
            if ~isequal(newColor,0)
                % Update the color
                obj.Value = newColor;
            end

            % Trigger event
            evtOut = wt.eventdata.ValueChangedData(obj.Value, oldValue);
            notify(obj,"ValueChanged",evtOut);

        end %function

        function onTextChanged(obj,evt)
            % Triggered on text interaction - subclass may override

            % Get prior value
            oldValue = obj.Value;

            % Trap errors
            try

                % Store new result
                obj.Value = str2num(evt.Value); %#ok<ST2NM>

                % Trigger event
                evtOut = wt.eventdata.ValueChangedData(obj.Value, oldValue);
                notify(obj,"ValueChanged",evtOut);

            catch

                % Restore original value
                obj.update();

            end %try

        end %function

    end %methods

    %% Accessors
    methods

        function set.ShowEditField(obj,value)
            obj.ShowEditField = value;
            obj.updateFieldVisibility()
        end

    end % methods

end % classdef

author: Arrowstar

repo: ksptot

save_path: github-repos/MATLAB/Arrowstar-ksptot


text:
function varargout = CamSeqGUI(varargin)
% CAMSEQGUI M-file for CamSeqGUI.fig
%      CAMSEQGUI, by itself, creates a new CAMSEQGUI or raises the existing
%      singleton*.
%
%      H = CAMSEQGUI returns the handle to a new CAMSEQGUI or the handle to
%      the existing singleton*.
%
%      CAMSEQGUI('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in CAMSEQGUI.M with the given input arguments.
%
%      CAMSEQGUI('Property','Value',...) creates a new CAMSEQGUI or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before CamSeqGUI_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to CamSeqGUI_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

% Copyright 2002-2003 The MathWorks, Inc.

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

% Last Modified by GUIDE v2.5 19-Sep-2004 12:05:37

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @CamSeqGUI_OpeningFcn, ...
                   'gui_OutputFcn',  @CamSeqGUI_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 CamSeqGUI is made visible.
function CamSeqGUI_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 CamSeqGUI (see VARARGIN)

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

% Update handles structure
guidata(hObject, handles);

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

% --- Outputs from this function are returned to the command line.
function varargout = CamSeqGUI_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)
set(handles.figure1,'Visible','off');
period = input(' Period in seconde between this view and the previous? > ');
set(handles.figure1,'Visible','on');
figure(1)
if isempty(period),
    period = 2;
end
handles.cam = CamSeqUpdate(handles.cam,period);
guidata(hObject,handles);

% --- 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)
set(handles.figure1,'Visible','off');
handles.fps = input(' Number of Frame per second? > ');
set(handles.figure1,'Visible','on');
figure(1)
if isempty(handles.fps),
    handles.fps = 20;
end
handles.seq = CamSeqGen(handles.cam,handles.fps);
guidata(hObject,handles);

% --- 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)
set(handles.figure1,'Visible','off');
handles.filename = input(' File name for the avi? > ','s');
set(handles.figure1,'Visible','on');
figure(1)
CamSeqPlay(handles.seq,handles.fps,handles.filename);
guidata(hObject,handles);

% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(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)
figure(1)
handles.cam = CamSeqUpdate([]);
guidata(hObject,handles);

author: Sable

repo: mcbench-benchmarks


text:
label='';
for k = 1:5
if k==1
    label='_gau_001';
end
if k==2
    label='_gau_0005';
end
if k==3
    label='_sp_01';
end
if k==4
    label='_sp_02';
end
if k==5
    label='_poi';
end
disp(label);

for i=1:10
index = i;

fused_path = ['./fused_mf_noise/fused',num2str(i),label,'_cbf.png'];
fused_path_new = ['./fused_mf_noise/fused',num2str(i),label,'_convsr.png'];

im=imread(fused_path);
imwrite(im,fused_path_new);
delete(fused_path);
end
end

author: thfylsty


text:
% procedure: use draw_anatomical_ROI_2008 to draw saggital slices
% then mask with cortical ribbon from segmentation
% then clean up using draw...

cl = mask2clusters('insula_ribbon_R.img');
cl = mask2clusters('SPM8_insula_ribbon_L.img');
mask_union([],'SPM8_insula_ribbon_LR.img','SPM8_insula_ribbon_L.img','insula_ribbon_R.img');
dat = fmri_data('SPM8_insula_ribbon_LR.img'); orthviews(dat)

dat = apply_mask(dat, fmri_data('SPM8_colin27T1_cortical_ribbon.img'));
orthviews(dat)

dat.fullpath = fullfile(pwd, 'insula_ribbon1.img');
write(dat);

%% clean up

draw_anatomical_roi_2008('load', 'insula_ribbon1.img')
draw_anatomical_roi_2008('moveslice')
draw_anatomical_roi_2008('write')
SPM8_insula_ribbon_LR.img

% smooth and threshold
dat = fmri_data('SPM8_insula_ribbon_LR.img')
dat = preprocess(dat, 'smooth', 1);
dat = threshold(dat, [.02 Inf], 'raw-between');
orthviews(dat)

%%
% viz
cl = mask2clusters('SPM8_insula_ribbon_LR.img');

cluster_orthviews(cl, {[1 .7 0]});
cluster_orthviews(cl, {[1 .7 0]}, 'add');

spm_orthviews('xhairs', 'off');
delete(findobj(gcf, 'Type', 'text'));

%%
dat = fmri_data('SPM8_insula_ribbon_LR.img')
orthviews(dat)
surface(dat)

author: canlab

repo: CanlabCore

save_path: github-repos/MATLAB/canlab-CanlabCore


text:
function bernstein_polynomial_test04 ( )

%*****************************************************************************80
%
%% BERNSTEIN_POLYNOMIAL_TEST04 tests BERNSTEIN_POLY_AB_APPROX.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    11 July 2011
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'BERNSTEIN_POLYNOMIAL_TEST04\n' );
  fprintf ( 1, '  BERNSTEIN_POLY_AB_APPROX evaluates the Bernstein polynomial\n' );
  fprintf ( 1, '  approximant to a function F(X).\n' );

  a = 1.0;
  b = 3.0;

  fprintf ( 1, '\n' );
  fprintf ( 1, '     N      Max Error\n' );
  fprintf ( 1, '\n' );

  for degree = 0 : 20
%
%  Generate data values.
%
    xdata = zeros ( degree + 1, 1 );
    ydata = zeros ( degree + 1, 1 );

    for i = 0 : degree

      if ( degree == 0 )
        xdata(i+1) = 0.5 * ( a + b );
      else
        xdata(i+1) = ( ( degree - i ) * a   ...
                     + (          i ) * b ) ...
                     / ( degree     );
      end

      ydata(i+1) = sin ( xdata(i+1) );

    end
%
%  Compare the true function and the approximant.
%
    nval = 501;

    xval = linspace ( a, b, nval );

    yval = bernstein_poly_ab_approx ( degree, a, b, ydata, nval, xval );

    error_max = max ( abs ( yval(1:nval) - sin ( xval(1:nval) ) ) );

    fprintf ( 1, '  %4d  %14.6g\n', degree, error_max );

  end

  return
end


text:
%   CLASS Reflectometry
% =========================================================================
%
% DESCRIPTION
%   Class to manage reflectometry functions
%
% EXAMPLE
%   rfx = Reflectometry();
%
% CONSTRUCTOR SYNTAX
%   rfx = Reflectometry();
%
% FOR A LIST OF CONSTANTs and METHODS use doc Reflectometry
%
% COMMENTS
% The class stores arrays of time, not just a single element,
% it has been designed this way because MATLAB works best on arrays
%

%--- * --. --- --. .--. ... * ---------------------------------------------
%               ___ ___ ___
%     __ _ ___ / __| _ | __|
%    / _` / _ \ (_ |  _|__ \
%    \__, \___/\___|_| |___/
%    |___/                    v 1.0RC1
%
%--------------------------------------------------------------------------
%  Copyright (C) 2021 Geomatics Research & Development srl (GReD)
%  Written by:        Andrea Gatti
%  Contributors:      Andrea Gatti, ...
%  A list of all the historical goGPS contributors is in CREDITS.nfo
%--------------------------------------------------------------------------
%
%   This program is free software: you can redistribute it and/or modify
%   it under the terms of the GNU General Public License as published by
%   the Free Software Foundation, either version 3 of the License, or
%   (at your option) any later version.
%
%   This program is distributed in the hope that it will be useful,
%   but WITHOUT ANY WARRANTY; without even the implied warranty of
%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%   GNU General Public License for more details.
%
%   You should have received a copy of the GNU General Public License
%   along with this program.  If not, see <http://www.gnu.org/licenses/>.
%
%--------------------------------------------------------------------------
% 01100111 01101111 01000111 01010000 01010011
%--------------------------------------------------------------------------

classdef Reflectometry < handle

    properties (Constant, GetAccess = public)
    end

    properties (SetAccess = public, GetAccess = public) % set permission have been changed from private to public (Giulio)
    end

    % =========================================================================
    %
    % =========================================================================

    methods
        function this = Reflectometry()
            % Constructor
            %
            % SYNTAX
            %   t = Coordinates();
        end
    end

    % =========================================================================
    %    TESTS
    % =========================================================================

    methods (Static, Access = 'public')
        function getAvgNyquist(rec, el_lim)
            % Show fresnel zones for a receiver
            %
            % INPUT
            %   rec     receiver
            %   el_lim  elevation limits [deg] (e.g. [5 15])
            %
            % SYNTAX
            %   Reflectometry.getAvgNyquist(rec, getAvgNyquist)
            log = Core.getLogger();
            cc = Core.getConstellationCollector;

            diff_el_crit = abs(diff(el_lim)) - 2;
            for r = 1 : numel(rec)
                work = rec(r).work;
                log.addMessage('Displaying fresnel zones for the receiver rec %s', rec(r).getMarkerName);
                [snr, id_snr] =  = work.getSNR();
                id_snr = find(id_snr);
                [az, el] = work.getAzEl(work.go_id(id_snr));
                azi = 0;
                [lat, lon, h_ellips] = work.getMedianPosGeodetic();
                freq_list = freq_list = unique(work.obs_code(id_snr,2));
                for f = 1 : numel(freq_list)
                    id_f = find(work.obs_code(id_snr,2) == freq_list(f));
                    for s = 1 : numel(id_f)
                        sat_name = cc.getSatName(work.go_id(id_snr(id_f(s))));
                        % find data within 20 degrees of azimuth and using elevation angle limits
                        id_ok = el(:,id_f(s)) >= el_lim(1) & el(:,id_f(s)) >= el_lim(2);
                        % sin of elevation
                        sin_el = sind(el(id_ok, id_f(s)));
                        % elevation limits
                        diff_el = max(el(id_ok, id_f(s))) - min(el(id_ok, id_f(s)));
                        diff_t = 2 * (max(sin_el) - min(sin_el)) / work.wl(id_snr(id_f(s)));
                        if diff_el > diff_el_crit
                            fprintf(1,'%s Azim. %6.2f  Nyquist %7.2f (m) %s ElevAngles: %3.0f %3.0f \n', ...
              sat_name, azi, avg_nyq, riseORset(riseset), minElevAngle, maxElevAngle);
                            avg_nyq = sum(id_ok) / (2 * diff_t);
                        end
                    end
                end
            end
        end
    end

end

author: goGPS-Project


text:
filename='Cantilever_tetrahedra_fine';
 ptype = 'MACRO';
method = 'SIMPALL';
materialType = 'ISOTROPIC';
initial_case = 'full';
cost = {'compliance'};
weights = [1, 0.1];
constraint = {'volumeConstraint'};
optimizer = 'MMA';
incrementFactor = 1;
designVariable = 'Density';
filterType = 'P1';

nsteps = 5;
Vfrac_final = 0.05;
Perimeter_target = 1;
optimality_final = 1e-3;
constr_final =1e-3;

Vfrac_initial = 1;
optimality_initial = 1e-2;
constr_initial = 1e-3;
TOL.rho_plus = 1;
TOL.rho_minus = 0;
TOL.E_plus = 1;
TOL.E_minus = 1e-3;
TOL.nu_plus = 1/3;
TOL.nu_minus = 1/3;

author: SwanLab

repo: Swan

save_path: github-repos/MATLAB/SwanLab-Swan


text:
clear;
%% load file (courtesy of C. Lacefield and R. Bruno, Columbia University)

addpath(genpath('../../ca_source_extraction'));
nam = 'dendritic_demo.tif';
if ~exist(nam,'file')  % download file if it doesn't exist in the directory
    url = 'https://www.dropbox.com/s/wykkq4lwoo85ml5/dendritic_demo.tif.zip?dl=1';
    filename = 'dendritic_demo.zip';
    outfilename = websave(filename,url);
    unzip(filename);
end

Y = bigread2(nam);
Y = Y - min(Y(:));
if ~isa(Y,'double');    Y = double(Y);  end         % convert to double

[d1,d2,T] = size(Y);                                % dimensions of dataset
d = d1*d2;                                          % total number of pixels

%% view data

nY = quantile(Y(:),0.01);
mY = quantile(Y(:),0.995);

figure;
for t = 1:4:T
    imagesc(Y(:,:,t),[nY,mY]);
    title(sprintf('Frame %i out of %i',t,T),'fontweight','bold','fontsize',14);
    drawnow;
    pause(0.01);
end

%% Set parameters

K = 50;                                           % number of components to be found
tau = [];                                         % std of gaussian kernel (size of neuron - not needed for dendritic data)
p = 0;                                            % No AR dynamics for dendritic data
merge_thr = 0.8;                                  % merging threshold

options = CNMFSetParms(...
    'd1',d1,'d2',d2,...                           % dimensions of datasets
    'init_method','HALS',...                      % initialize algorithm with plain NMF
    'max_iter_hals_in',50,...                     % maximum number of iterations
    'search_method','dilate',...                  % search locations when updating spatial components
    'temporal_iter',2,...                         % number of block-coordinate descent steps
    'merge_thr',0.8,...                           % merging threshold
    'conn_comp',false,...                         % do not limit to largest connected component for each found component
    'maxthr',0.05...                              % for every component set pixels that are below max_thr*max_value to 0
    );
%% Data pre-processing

[P,Y] = preprocess_data(Y,p);

%% fast initialization of spatial components using greedyROI and HALS

[Ain,Cin,bin,fin,center] = initialize_components(Y,K,tau,options,P);  % initialize

Yr = reshape(Y,d,T);
plot_dend_components_GUI(Yr,Ain,Cin,bin,fin,options);  % view the components

%% update spatial components

[A,b,Cin] = update_spatial_components(Yr,Cin,fin,[Ain,bin],P,options);

%% update temporal components

[C,f,P,S] = update_temporal_components(Yr,A,b,Cin,fin,P,options);

%% merge found components
[Am,Cm,K_m,merged_ROIs,P,Sm] = merge_components(Yr,A,b,C,f,P,S,options);

display_merging = 1; % flag for displaying merging example
if and(display_merging, ~isempty(merged_ROIs))
    i = 1; %randi(length(merged_ROIs));
    ln = length(merged_ROIs{i});
    figure;
        set(gcf,'Position',[300,300,(ln+2)*300,300]);
        for j = 1:ln
            subplot(1,ln+2,j); imagesc(reshape(A(:,merged_ROIs{i}(j)),d1,d2));
                title(sprintf('Component %i',j),'fontsize',16,'fontweight','bold'); axis equal; axis tight;
        end
        subplot(1,ln+2,ln+1); imagesc(reshape(Am(:,K_m-length(merged_ROIs)+i),d1,d2));
                title('Merged Component','fontsize',16,'fontweight','bold');axis equal; axis tight;
        subplot(1,ln+2,ln+2);
            plot(1:T,(diag(max(C(merged_ROIs{i},:),[],2))\C(merged_ROIs{i},:))');
            hold all; plot(1:T,Cm(K_m-length(merged_ROIs)+i,:)/max(Cm(K_m-length(merged_ROIs)+i,:)),'--k')
            title('Temporal Components','fontsize',16,'fontweight','bold')
        drawnow;
else
    fprintf('No components were merged. \n')
end

%% order and extract DF/F

[A_or,C_or,S_or,P] = order_ROIs(A,C,S,P); % order components
K_m = size(C_or,1);
[C_df,~] = extract_DF_F(Yr,[A_or,b],[C_or;f],K_m+1); % extract DF/F values (optional)

%% display components

plot_dend_components_GUI(Yr,A_or,C_or,b,f,options)

%% make movie

make_dendritic_video(A_or,C_or,b,f,Yr,d1,d2)

author: flatironinstitute

repo: CaImAn-MATLAB


text:
function [xi,w]=eighthOrderTriangleCubPoints(algorithm)
%%EIGHTHORDERTRIANGLECUBPOINTS Obtain eighth-order cubature points for
%   integration over a triangle in 2D. The points and weights are for the
%   triangle with vertices (1,0), (0,1), (0,0), but can be transformed to
%   any triangle using transformSimplexTriPoints.
%
%INPUTS: algorithm An optional parameter selecting the algorithm for the
%                  specific point set. Possible values are:
%                  0 (The default if omitted or an empty matrix is passed)
%                    Use the algorithm of [1] (16 points).
%                  1 Use the 8th order points found using the algorithm of
%                    [2], given in the supplementary material of [2] (16
%                    points).
%
%OUTPUTS: xi A 2XnumCubPoints set of points for the standard triangle.
%          w A 1XnumCubPoints set of cubature weights. This sums to the
%            volume of the triangle (1/2).
%
%This function implements the points given in [1] and [2].
%
%EXAMPLE:
%Given the vertices of the simplex, we compare an eighth-order moment
%computed using these cubature points to one computed using
%monomialIntSimplex. The results are the same within typical finite
%precision limits.
% [xi,w]=eighthOrderTriangleCubPoints();
% alpha=[6;2];
% theMoment=findMomentFromSamp(alpha,xi,w)
% intVal=monomialIntSimplex(alpha)
%
%REFERENCES:
%[1]L. Zhang and T. Cui, "A set of symmetric quadrature rules on triangles
%   and tetrahedra," Journal of Computational Mathematics, vol. 27, no. 1,
%   pp. 89-96, Jan. 2009.
%[2] F. D. Witherden and P. E. Vincent, "On the identification of symmetric
%    quadrature rules for finite element methods," Computer and Mathematics
%    with Applications, vol. 69, no. 10, pp. 1232-1241, May 2015.
%
%October 2022 David F. Crouse, Naval Research Laboratory, Washington D.C.
%(UNCLASSIFIED) DISTRIBUTION STATEMENT A. Approved for public release.

if(nargin<1||isempty(algorithm))
    algorithm=0;
end

switch(algorithm)
    case 0
        w1=0.1443156076777871682510911104890646;
        w2=0.1032173705347182502817915502921290;
        w3=0.0324584976231980803109259283417806;
        w4=0.0950916342672846247938961043885843;
        w5=0.0272303141744349942648446900739089;
        w=[w1;w2;w2;w2;w3;w3;w3;w4;w4;w4;w5;w5;w5;w5;w5;w5];

        p1=0.3333333333333333333333333333333333;
        p2=0.1705693077517602066222935014914645;
        p3=0.0505472283170309754584235505965989;
        p4=0.4592925882927231560288155144941693;
        p5a=0.2631128296346381134217857862846436;
        p5b=0.0083947774099576053372138345392944;

        xiBary=zeros(3,16);
        xiBary(:,1)=[p1;p1;p1];
        xiBary(:,2:4)=genAllMultisetPermutations([p2;p2;1-2*p2]);
        xiBary(:,5:7)=genAllMultisetPermutations([p3;p3;1-2*p3]);
        xiBary(:,8:10)=genAllMultisetPermutations([p4;p4;1-2*p4]);
        xiBary(:,11:16)=genAllMultisetPermutations([p5a;p5b;1-p5a-p5b]);

        %Adjust w for the area of the standard triangle.
        w=w/2;

        %Convert the barycentric points into normal cubature points for the
        %standard triangle given the vertices.
        vertices=[1,0,0;
                  0,1,0];
        xi=barycentricCoords2Pt(xiBary,vertices);
    case 1
        M=[-0.33333333333333333333333333333333333333,   -0.33333333333333333333333333333333333333,     0.2886312153555743365021822209781292496;
          -0.081414823414553687942368971011661355879,   -0.83717035317089262411526205797667728824,     0.1901832685345692495877922087771686332;
           -0.83717035317089262411526205797667728824,  -0.081414823414553687942368971011661355879,     0.1901832685345692495877922087771686332;
          -0.081414823414553687942368971011661355879,  -0.081414823414553687942368971011661355879,     0.1901832685345692495877922087771686332;
           -0.65886138449647958675541299701707099796,    0.31772276899295917351082599403414199593,    0.20643474106943650056358310058425806003;
            0.31772276899295917351082599403414199593,   -0.65886138449647958675541299701707099796,    0.20643474106943650056358310058425806003;
           -0.65886138449647958675541299701707099796,   -0.65886138449647958675541299701707099796,    0.20643474106943650056358310058425806003;
           -0.89890554336593804908315289880680210631,    0.79781108673187609816630579761360421262,   0.064916995246396160621851856683561193593;
            0.79781108673187609816630579761360421262,   -0.89890554336593804908315289880680210631,   0.064916995246396160621851856683561193593;
           -0.89890554336593804908315289880680210631,   -0.89890554336593804908315289880680210631,   0.064916995246396160621851856683561193593;
           -0.98321044518008478932557233092141110162,    0.45698478591080856248200075835212392604,    0.05446062834886998852968938014781784832;
            0.45698478591080856248200075835212392604,   -0.98321044518008478932557233092141110162,    0.05446062834886998852968938014781784832;
           -0.47377434073072377315642842743071282442,    0.45698478591080856248200075835212392604,    0.05446062834886998852968938014781784832;
            0.45698478591080856248200075835212392604,   -0.47377434073072377315642842743071282442,    0.05446062834886998852968938014781784832;
           -0.47377434073072377315642842743071282442,   -0.98321044518008478932557233092141110162,    0.05446062834886998852968938014781784832;
           -0.98321044518008478932557233092141110162,   -0.47377434073072377315642842743071282442,    0.05446062834886998852968938014781784832];

        w=M(:,3);
        xi=M(:,1:2)';
        %Transform the points to the standard triangle.
        v1=[-1,-1, 1;
            -1, 1,-1];
        v2=[1,0,0;
            0,1,0];
        [A,d]=affineTransBetweenTriangles(v1,v2);
        xi=bsxfun(@plus,A*xi,d);
        w=w/4;
    otherwise
        error('Unknown Algorithm Specified')
end
end

%LICENSE:
%
%The source code is in the public domain and not licensed or under
%copyright. The information and software may be used freely by the public.
%As required by 17 U.S.C. 403, third parties producing copyrighted works
%consisting predominantly of the material produced by U.S. government
%agencies must provide notice with such work(s) identifying the U.S.
%Government material incorporated and stating that such material is not
%subject to copyright protection.
%
%Derived works shall not identify themselves in a manner that implies an
%endorsement by or an affiliation with the Naval Research Laboratory.
%
%RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF THE
%SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY THE NAVAL
%RESEARCH LABORATORY FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE ACTIONS
%OF RECIPIENT IN THE USE OF THE SOFTWARE.

author: USNavalResearchLaboratory

repo: TrackerComponentLibrary


text:
classdef SamplePointsCreatorFromMxMyForOptimalExponentComputer ...
        < SamplePointsCreatorForOptimalExponentComputer

    properties (Access = private)
        mxMax
        myMax
        mxMin
        myMin
        mxV
        myV
        superellipse
    end

    methods (Access = public)

        function obj = SamplePointsCreatorFromMxMyForOptimalExponentComputer(cParams)
            obj.init(cParams)
        end

    end

    methods (Access = private)

        function init(obj,cParams)
            nMx  = cParams.nMx;
            nMy  = cParams.nMy;
            nPhi = cParams.nPhi;
            phiMin = cParams.phiMin;
            phiMax = cParams.phiMax;
            obj.mxMax = 0.99;
            obj.myMax = 0.99;
            obj.mxMin = 0.01;
            obj.myMin = 0.01;
            obj.mxV = linspace(obj.mxMin,obj.mxMax,nMx);
            obj.myV = linspace(obj.myMin,obj.myMax,nMy);
            obj.phiV = linspace(phiMin,phiMax,nPhi);
            obj.superellipse = SuperEllipseParamsRelator();
        end

    end

    methods (Access = protected)

        function computeRhoTxiValues(obj)
            nmx = length(obj.mxV);
            nmy = length(obj.myV);
            q = 10^6;
            for imx = 1:nmx
                for imy = 1:nmy
                    mx = obj.mxV(imx);
                    my = obj.myV(imy);
                    index = nmx*(imy - 1) + imx;
                    obj.rhoV(index) = obj.superellipse.rho(mx,my,q);
                    obj.txiV(index) = obj.superellipse.txi(mx,my);
                end
            end
        end

    end

end


text:
function value = s_s_subanagram ( s1, s2 )

%*****************************************************************************80
%
%% S_S_SUBANAGRAM determines if S2 is a "subanagram" of S1.
%
%  Discussion:
%
%    S2 is an anagram of S1 if S2 can be formed by permuting the letters
%    of S1
%
%    S2 is an subanagram of S1 if S2 can be formed by selecting SOME of
%    the letters of S1 and permuting them.
%
%    Blanks (trailing or otherwise), punctuation, and capitalization
%    are all significant, so be sure to input exactly the information
%    you want to check.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    15 June 2007
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, string S1, the master string.
%
%    Input, string S2, the second string.
%
%    Output, logical VALUE is TRUE if S2 is a subanagram of S1.
%
  value = 0;
%
%  Sort both.
%
  s1 = s_sort_a ( s1 );
  s2 = s_sort_a ( s2 );

  s1_length = length ( s1 );
  s2_length = length ( s2 );

  i1 = 0;

  for i2 = 1 : s2_length

    while ( 1 )

      i1 = i1 + 1;
%
%  Ran out of S1 before finishing.  No match is possible.
%
      if ( s1_length < i1 )
        return;
      end
%
%  The current character in S1 is already greater than the character in S2.
%  No match is possible.
%
      if ( s2(i2) < s1(i1) )
        return
      end
%
%  Found an exact match for current character.  Keep going.
%
      if ( s1(i1) == s2(i2) )
        break
      end
%
%  Didn't find a match, but one might be possible if we increase I1.
%
    end

  end
%
%  We matched every character of S2 with something in S1.
%
  value = 1;

  return
end