text:
function aux_FMD(params, hParentFigure)
% function aux_FMD(params, hParentFigure);
%-------------------------------------------
%
% Incoming variables:
% params        : all variables
% hParentFigure : Handle of the parent figure
%
% J.Woessner, woessner@seismo.ifg.ethz.ch
% last update: 19.08.02

% Track of changes:
% 19.08.02: Replaced fcumulsum.m with calc_cumulsum.m

% Get the axes handle of the plotwindow
axes(sv_result('GetAxesHandle', hParentFigure, [], guidata(hParentFigure)));
hold on;
% Select a point in the plot window with the mouse
[fX, fY] = ginput(1);
disp(['X: ' num2str(fX) ' Y: ' num2str(fY)]);
% Plot a small circle at the chosen place
plot(fX,fY,'ok');

% Get closest gridnode for the chosen point on the map
[fXGridNode fYGridNode,  nNodeGridPoint] = calc_ClosestGridNode(params.mPolygon, fX, fY);
plot(fXGridNode, fYGridNode, '*r');
hold off;

% Get the data for the grid node
mNodeCatalog_ = params.mCatalog(params.caNodeIndices{nNodeGridPoint}, :);
%%%% Doe: Determine next grid point and earthquakes associated with it %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

params.fTimePeriod = params.fTimePeriod/365;
% Split the gridpoint catalog according to the defined Splittime
[mFirstCatalog, mSecondCatalog, fFirstPeriodExact, fSecondPeriodExact, fFirstPeriod,...
       result.fSecondPeriod] = ex_SplitCatalog(mNodeCatalog_, params.fSplitTime, params.bTimePeriod,...
   params.fTimePeriod, params.bTimePeriod, params.fTimePeriod);

% Create the frequency magnitude distribution vectors for the two time periods
[vFMDOrg, vNonFMDOrg] = calc_FMD(mNodeCatalog_);
[vFMD, vNonCFMD] = calc_FMD(mFirstCatalog);
[vFMDSecond, vNonCFMDSecond] = calc_FMD(mSecondCatalog);

if exist('new_fig','var') &  ishandle(new_fig)
   set(0,'Currentfigure',new_fig);
   disp('Figure exists');
else
    new_fig=figure_w_normalized_uicontrolunits('tag','bnew','Name','Cumulative FMD and b-value fit','Units','normalized','Nextplot','add','Numbertitle','off');
    new_axs=axes('tag','ax_bnew','Nextplot','add','box','on');
end
set(gca,'tag','ax_bnew','Nextplot','replace','box','on');
axs5=findobj('tag','ax_bnew');
axes(axs5(1));
semilogy(vFMD(1,:), vFMD(2,:),'-o');
hold on;
semilogy(vFMDOrg(1,:), vFMDOrg(2,:),'-k^');
semilogy(vFMDSecond(1,:), vFMDSecond(2,:),'-*','Color', [0 0.5 0]);
sColor = 'b';

% Calculate magnitude of completeness
fMc = calc_Mc(mFirstCatalog, params.nCalculateMC);
fMcSecond = calc_Mc(mSecondCatalog, params.nCalculateMC);

% First period
[nIndexLo, fMagHi, vSel, vMagnitudes] = fMagToFitBValue(mFirstCatalog, vFMD, fMc);
 % Calculate the b-value etc. for M > Mc
[fMeanMag, fBValue, fStdDev, fAValue] =  calc_bmemag(mFirstCatalog(vSel,:),0.1);
% Plot the 'x'-marker
hPlot = semilogy(vFMD(1,nIndexLo), vFMD(2,nIndexLo), ['x' sColor]);
set(hPlot, 'LineWidth', [2.5], 'MarkerSize', 12);
hPlot = semilogy(vFMD(1,1), vFMD(2,1), ['x' sColor]);
set(hPlot, 'LineWidth', [2.5], 'MarkerSize', 12)

% Plot the line representing the b-value
vPoly = [-1*fBValue fAValue];
fBFunc = 10.^(polyval(vPoly, vMagnitudes));
hPlot = semilogy(vMagnitudes, fBFunc, sColor);
set(hPlot, 'LineWidth', [2.0]);
txtInfoString = ['a: ' num2str(fAValue) ', b: ' num2str(fBValue) ', std: ' num2str(fStdDev)];
text(0.1, 1.1, txtInfoString, 'Color', [0 0 1]);

%% Temporaer
vFMD(2,nIndexLo)
%% Second period
sColor = 'g';
[nIndexLoSecond, fMagHiSecond, vSelSecond, vMagnitudesSecond] = fMagToFitBValue(mSecondCatalog, vFMDSecond, fMcSecond);
% Calculate the b-value etc. for M > Mc
[fMeanMagSecond, fBValueSecond, fStdDevSecond, fAValueSecond] =  calc_bmemag(mSecondCatalog(vSelSecond,:), 0.1);
% Plot the 'x'-marker
hPlot = semilogy(vFMDSecond(1,nIndexLoSecond), vFMDSecond(2,nIndexLoSecond), ['x' sColor]);
set(hPlot, 'LineWidth', [2.5], 'MarkerSize', 12);
hPlot = semilogy(vFMDSecond(1,1), vFMDSecond(2,1), ['x' sColor]);
set(hPlot, 'LineWidth', [2.5], 'MarkerSize', 12)

% Plot the line representing the b-value
vPolySecond = [-1*fBValueSecond fAValueSecond];
fBFuncSecond = 10.^(polyval(vPolySecond, vMagnitudesSecond));
hPlot = semilogy(vMagnitudesSecond, fBFuncSecond, 'Color', [0 0.5 0]);
set(hPlot, 'LineWidth', [2.0]);
txtInfoString = ['a: ' num2str(fAValueSecond) ', b: ' num2str(fBValueSecond) ', std: ' num2str(fStdDevSecond)];
text(0.1, 1.4, txtInfoString, 'Color', [0 0.5 0]);

% Determine magnitude shift
fMintercept = 1/fBValueSecond*(fAValueSecond-log10(vFMD(2,nIndexLo)));
fMshift = fMintercept - vFMD(1,nIndexLo);

% Entire plot labels
xlabel('Magnitude');
ylabel('Cumulative sum per grid node');
if params.bTimePeriod == 0
    sTitleString = ['o: ' num2str(min(mFirstCatalog(:,3))) ' - ' num2str(max(mFirstCatalog(:,3))) ' *: ' num2str(min(mSecondCatalog(:,3)))...
        ' - ' num2str(max(mSecondCatalog(:,3)))];
else
    sTitleString = ['o: ' num2str(params.fSplitTime-params.fTimePeriod) ' - ' num2str(params.fSplitTime) ' *: ' num2str(params.fSplitTime)...
        ' - ' num2str(params.fSplitTime+params.fTimePeriod)];
end
title(sTitleString);
hold off;


text:
function [isfound, foundvalue, properties] = getproperty(desiredproperty,properties,defaultvalue)
%GETPROPERTY returns a property value from a property list, or a default
%  value if none is available
%[isfound, foundvalue, properties] =
%      getproperty(desiredproperty,properties,defaultvalue)
%
% returns a property value (if found) from a property list, removing that
% property pair from the list.  only removes the first encountered property
% name.
%
%see also waveform/private/parseargs, waveform/private/property2varargin

pmask = strcmpi(desiredproperty,properties.name);
isfound = any(pmask);
if isfound
  foundlist = find(pmask);
  foundidx = foundlist(1);
  foundvalue = properties.val{foundidx};
  properties.name(foundidx) = [];
  properties.val(foundidx) = [];
else
  if exist('defaultvalue','var')
    foundvalue = defaultvalue;
  else
    foundvalue = [];
  end
  % do nothing to properties...
end

author: geoscience-community-codes

repo: GISMO


text:
function [p,s]=permutes(n)
%PERMUTES All N! permutations of 1:N + signatures [P,S]=(N)
% The output P is a matrix of size (N!,N) where each row
% contains a permutation of the numbers 1:N. The rows are in
% lexically sorted order.
%
% To permute the elements of an arbitrary vector V use
% V(PERMUTES(LENGTH(V))).

% PERMUTES(N) is the same as SORTROWS(PERMS(1:N)) but much faster.

% Thanks to Peter J Acklam for several improvements.

%      Copyright (c) 1998 Mike Brookes,  mike.brookes@ic.ac.uk
%      Version: $Id: permutes.m 713 2011-10-16 14:45:43Z dmb $
%
%   VOICEBOX is a MATLAB toolbox for speech processing.
%   Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   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 2 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 can obtain a copy of the GNU General Public License from
%   http://www.gnu.org/copyleft/gpl.html or by writing to
%   Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

p=1;
m=1;
if n>1
  for a=2:n
    q=zeros(a*m,a);
    r=2:a+1;
       ix=1:m;
    for b=1:a
       q(ix,1)=b;
      q(ix,2:a)=r(p);
      r(b)=b;
      ix=ix+m;
    end
    m=m*a;
    p=q;
  end
end
if nargout>1 s=1-2*rem(fix((1:m)'/2),2); end

author: jtkim-kaist

repo: VAD

save_path: github-repos/MATLAB/jtkim-kaist-VAD


text:
function dim = imSize(img, varargin)
%IMSIZE  Compute the size of an image in [x y z] order
%
%   SIZ = imSize(IMG)
%   Returns the size of the image, in x-y-z order, for a grayscale or a
%   color image.
%   In the case of a 3D color image, returns only the 3 physical dimensions
%   of the image.
%
%   S = imSize(IMG, DIR)
%   Return the size of the image in the specified direction.
%   DIR=1 corresponds to X axis (second direction of matlab array)
%   DIR=2 corresponds to Y axis (first direction of matlab array)
%   DIR=3 corresponds to Z axis (third or fourth direction of matlab array)
%
%   S = imSize(IMG, RESOL)
%   Return the size of the image in physical units. RESOL is a 1-by-3 row
%   vector containing resolution in x, y and z directions respectively.
%
%
%   Example
%   % Compute the size of a color image
%     img = imread('peppers.png');
%     imSize(img)
%     ans =
%        512   384
%     (returns the width, then the height)
%
%   % compute size of a portion of MRI image
%     img = analyze75read(analyze75info('brainMRI.hdr'));
%     img2 = img(1:50, :, :);   % keep 50 rows, in the y-direction
%     imSize(img2)
%     ans =
%        128    50    27
%   % (the number of voxels in y-direction is given as second parameter)
%
%   % return only the number of rows, i.e. the number of voxels in the
%   % Y-direction
%     ny = imSize(img2, 2)
%     ny =
%         50
%
%   See also
%     imPhysicalExtent, size, ndims
%
%
% ------
% Author: David Legland
% e-mail: david.legland@grignon.inra.fr
% Created: 2010-07-01,    using Matlab 7.9.0.529 (R2009b)
% Copyright 2010 INRA - Cepia Software Platform.

% size of matlab array
dim = size(img);

% remove color dimension if necessary
if isColorImage(img)
    dim(3) = [];
end

% swap x-y dimensions
nd = length(dim);
dim = dim([2 1 3:nd]);

if ~isempty(varargin)
    var = varargin{1};

    if isscalar(var)
        % in case a single direction is asked, select it
        dim = dim(varargin{1});

    elseif length(var) == length(dim)
        % if resolution is specified, compute size in physical units
        dim = dim .* var;
    end
end

author: mattools

repo: matImage

save_path: github-repos/MATLAB/mattools-matImage


text:
function kern = gibbsKernParamInit(kern)

% GIBBSKERNPARAMINIT GIBBS kernel parameter initialisation.
% This is the non stationary kernel proposed by Mark Gibbs in his 1997
% thesis. It is similar to an RBF but has a length scale that varies
% with input location. This leads to an additional term in front of
% the kernel.
%
% Given
% r = sqrt((x_i - x_j)'*(x_i - x_j))
%
% we have
% k(x_i, x_j) = sigma2*Z*exp(-r^2/(l(x)*l(x) + l(x')*l(x')))
%
% where
% Z = sqrt(2*l(x)*l(x')/(l(x)*l(x) + l(x')*l(x'))
%
% The parameters are sigma2, the process variance (kern.variance),
% and the parameters of l(x) which is a function that can be specified by the user, by default an MLP is used.
%
% SEEALSO : mlpCreate, gibbsKernSetLengthScaleFunc
%
% FORMAT
% DESC initialises Mark Gibbs's non-stationary
%  kernel structure with some default parameters.
% ARG kern : the kernel structure which requires initialisation.
% RETURN kern : the kernel structure with the default parameters placed in.
%
% SEEALSO : kernCreate, kernParamInit
%
% COPYRIGHT : Neil D. Lawrence, 2006

% KERN

kern.variance = 1;
options = mlpOptions(5);
kern.lengthScaleFunc = modelCreate('mlp', kern.inputDimension, 1, options);
kern.lengthScaleTransform = optimiDefaultConstraint('positive');

kern.nParams = 1+kern.lengthScaleFunc.numParams;

kern.transforms.index = kern.nParams;
kern.transforms.type = optimiDefaultConstraint('positive');

kern.isStationary = false;

author: SheffieldML

repo: GPmat

save_path: github-repos/MATLAB/SheffieldML-GPmat


text:
%PRWAITBARONCE Generate single prwaitbar message
%
%	PRWAITBARONCE(STRING,PAR)
%
% INPUT
%   STRING  - String with text to be written in the waitbar,
%             e.g. '%i x %i eigenvalue decomposition: '.
%             This will be parsed by S = SPRINTF(STRING,PAR{:});
%   PAR     - scalar or cell array with parameter values
%
% This routine has to be used in combination with PRWAITBAR(0), e.g.:
%
%  prwaitbaronce('%i x %i eigenvalue decomposition ... ',{n,n})
%  [Q,L] = eig(H);
%  prwaitbar(0)
%
% It makes clear to the user what is happening in case progress cannot be
% accessed.

% Copyright: R.P.W. Duin, r.p.w.duin@37steps.com

function prwaitbaronce(ss,par)

	if nargin < 2
		prwaitbar(2,ss);
	elseif ~iscell(par)
		prwaitbar(2,sprintf(ss,par));
	else
		prwaitbar(2,sprintf(ss,par{:}));
	end

return

author: marianux

repo: ecg-kit

save_path: github-repos/MATLAB/marianux-ecg-kit


text:
function C = mtimes(A, B)
%*   CHEBOP composition, multiplication, or application.
%   C = A*B, where either A or B is a scalar, returns a CHEBOP C representing
%   scalar multiplication of the original operator.  Boundary conditions
%   are copied from A or B to C.
%
%   If N is a CHEBOP and U a CHEBFUN or CHEBMATRIX of dimension compatible
%   with N.op, then N*U is equivalent to FEVAL(N, U).
%
%   C = A*B, where A and B are CHEBOP objects, should return a CHEBOP C
%   representing the composition of the operators of A and B. Boundary
%   conditions on A or B are destroyed by this process. Note this is not yet
%   supported.
%
% See also CHEBOP/PLUS, CHEBOP/MINUS, CHEBOP/MLDIVIDE, CHEBOP/FEVAL

% Copyright 2017 by The University of Oxford and The Chebfun Developers.
% See http://www.chebfun.org/ for Chebfun information.

if ( isa(A, 'chebfun') )
    error('CHEBFUN:CHEBOP:mtimes:invalid', 'Operation is undefined.');

elseif ( isa(B, 'chebfun') || isa(B, 'chebmatrix') )
    % Let A operate on B:
    C = feval(A, B);

elseif ( isnumeric(B) )
    % Switch argument to make sure A is numeric:
    C = mtimes(B, A);

elseif ( isnumeric(A) )

    if ( ~isscalar(A) )
        error('CHEBFUN:CHEBOP:mtimes:nonScalar', ...
            'CHEBOP * DOUBLE multiplication is defined only for scalars.');
    end

    % Initialize C as a CHEBOP
    C = B;

    % Make the pretty string:
    funArgs = getFunArgs(C);
    argStr = ['@(',funArgs,')'];
    if ( ~isempty(C.opShow) )
        op = C.opShow;
    else
        op = func2str(C.op);
    end
    C.opShow = strrep(op, argStr, [argStr num2str(A) '*']);

    % Multiplication of anonymous functions is not supported in Matlab. Need to
    % work around that.
    C.op = eval(['@(', funArgs, ') A*C.op(', funArgs, ')']);

elseif ( isa(A,'chebop') && isa(B,'chebop') )
    % CHEBOP composition is not yet supported. It will probably be a mess once
    % we start getting systems involved, as the inputs need to be shuffled
    % correctly. A remedy might be through a nested function in this file.
    error('CHEBFUN:CHEBOP:mtimes:notSupported1',...
        'CHEBOP composition is not supported.');

else
    error('CHEBFUN:CHEBOP:mtimes:notSupported2', ...
        '%s * %s multiplication is not supported.', class(A), class(B));

end

end

author: chebfun

repo: chebfun

save_path: github-repos/MATLAB/chebfun-chebfun


text:
function s = docMessage()
  s = 'Read the docs at: https://openocl.org/api-docs/';

author: OpenOCL

repo: OpenOCL

save_path: github-repos/MATLAB/OpenOCL-OpenOCL