text:
function aList=genAllBinCombinations(n,t,algorithm)
%%GENALLBINARYCOMBINATIONS Generate all combinations of t items chosen from
%              a set of n items, presenting the results as binary strings.
%
%INPUTS: n The number of items from which t items are chosen .
%        t The number of items chosen, t<=n.
% algorithm An optional parameter affecting which algorithm is used (and
%          thus the ordering of the codes). Possible values are:
%          0 (The default if omitted or an empty matrix is passed). Use
%            Algorithm C in Chapter 7.2.1.3 of [1]. The combinations are
%            given in the order of Chase's sequence.
%          1 Use Algorithm 2 in [2]. The combinations are given as a gray
%            code. Consecutive combinations differ in only 2 bits.
%
%OUTPUTS: aList An nXnumCombos list of all of the binary strings of n bits
%               choosing t of them to be 1.
%
%There is a total of numCombos=binomial(n,t) combinations.
%
%EXAMPLE:
% aList0=genAllBinCombinations(4,2,0)
% aList1=genAllBinCombinations(4,2,1)
%One will find that
% aList0=[0, 1, 0, 0, 1, 1;
%         0, 0, 1, 1, 0, 1;
%         1, 0, 0, 1, 1, 0;
%         1, 1, 1, 0, 0, 0];
% aList1=[1, 0, 1, 0, 0, 1;
%         1, 1, 0, 0, 1, 0;
%         0, 1, 1, 1, 0, 0;
%         0, 0, 0, 1, 1, 1];
%
%REFERENCES:
%[1] D. E. Knuth, The Art of Computer Programming. Vol. 4A: Combinatorial
%    Algorithms, Part I, Boston: Addison-Wesley, 2011.
%[2] J. R. Bitner, G. Ehrlich, and E. M. Reingold, "Efficient generation of
%    the binary reflected gray code and its applications," Communications
%    of the ACM, vol. 19, no. 9, pp. 517-521, Sep. 1976.
%
%October 2018 David F. Crouse, Naval Research Laboratory, Washington D.C.
%(UNCLASSIFIED) DISTRIBUTION STATEMENT A. Approved for public release.

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

switch(algorithm)
    case 0
        aList=genAllBinCombinationsKnuth(n,t);
    case 1
        aList=genAllBinCombinationsGray(n,t);
    otherwise
        error('Unknown algorithm specified.')
end

end

function aList=genAllBinCombinationsKnuth(n,t)
%%GENALLBINARYCOMBINATIONS Generate all combinations of t items chosen from
%              a set of n items, presenting the results as binary strings.
%
%INPUTS: n The number of items from which t items are chosen.
%        t The number of items chosen, t<=n.
%
%OUTPUTS: aList An nXnumCombos list of all of the binary strings of n bits
%               choosing t of them to be 1.
%
%There is a total of numCombos=binomial(n,t) combinations. Algorithm C in
%Chapter 7.2.1.3 of [1] is used to generate the strings in the order of
%Chase's sequence.
%
%EXAMPLE:
% aList=genAllBinCombinations(4,2)
%One will find that
% aList=[0,1,0,0,1,1;
%        0,0,1,1,0,1;
%        1,0,0,1,1,0;
%        1,1,1,0,0,0];
%
%REFERENCES:
%[1] D. E. Knuth, The Art of Computer Programming. Vol. 4A: Combinatorial
%    Algorithms, Part I, Boston: Addison-Wesley, 2011.
%
%October 2018 David F. Crouse, Naval Research Laboratory, Washington D.C.

if(t==n)
    aList=ones(n,1);
    return
elseif(t==0)
    aList=zeros(n,1);
    return
end

s=n-t;

numCombos=binomial(n,t);
aList=zeros(n,numCombos);

%Step C1. a and w are indexed from 0 in [1].
a=[zeros(s,1);ones(t,1)];%
w=ones(n+1,1);
r=s;

for curCombo=1:numCombos
    %Step C1
    aList(:,curCombo)=a;

    %Step C3
    j=r;
    while(w(j+1)==0)
        w(j+1)=1;
        j=j+1;
        if(j==n)
            return;
        end
    end

    w(j+1)=0;
    if(mod(j,2)==1)%j is odd
        if(a(j+1)~=0)
            %Step C4
            a(j-1+1)=1;
            a(j+1)=0;
            if(r==j&&j>1)
                r=j-1;
            elseif(r==j-1)
                r=j;
            end
        else
            %Step C7
            if(a(j-1+1)~=0)
                %Step C6
                a(j+1)=1;
                a(j-1+1)=0;
                if(r==j&&j>1)
                    r=j-1;
                elseif(r==j-1)
                    r=j;
                end
            else
               a(j+1)=1;
               a(j-2+1)=0;
               if(r==j-2)
                   r=j;
               elseif(r==j-1)
                   r=j-2;
               end
            end
        end
    else%j is even
        if(a(j+1)~=0)
            %Step C5
            if(a(j-2+1)~=0)
                %Step C4
                a(j-1+1)=1;
                a(j+1)=0;
                if(r==j&&j>1)
                    r=j-1;
                elseif(r==j-1)
                    r=j;
                end
            else
                a(j-2+1)=1;
                a(j+1)=0;
                if(r==j)
                    r=max(j-2,1);
                elseif(r==j-2)
                    r=j-1;
                end
            end
        else
            %Step C6
            a(j+1)=1;
            a(j-1+1)=0;
            if(r==j&&j>1)
                r=j-1;
            elseif(r==j-1)
                r=j;
            end
        end
    end

end

end

function theCodes=genAllBinCombinationsGray(n,k)
%%GENALLBINCOMBINATIONSGRAY Generate all combinations of k items chosen
%              from a set of n items, presenting the results as binary
%              strings. Subsequent combinations differ by 2 bits.
%
%INPUTS: n The number of items from which k items are chosen.
%        t The number of items chosen, t<=n.
%
%OUTPUTS: aList An nXnumCombos list of all of the binary strings of n bits
%               choosing k of them to be 1.
%
%There is a total of numCombos=binomial(n,t) combinations. Algorithm 2 in
%[1] is used to generate all combinations are a gray code. Subsequent
%combinations differ in only 2 bits.
%
%REFERENCES:
%[1] J. R. Bitner, G. Ehrlich, and E. M. Reingold, "Efficient generation of
%    the binary reflected gray code and its applications," Communications
%    of the ACM, vol. 19, no. 9, pp. 517-521, Sep. 1976.
%
%July 2019 David F. Crouse, Naval Research Laboratory, Washington D.C.

if(k==0)
    theCodes=zeros(n,1);
    return;
end

numCodes=binomial(n,k);
theCodes=zeros(n,numCodes);

g=[ones(k,1);zeros(n-k+2,1)];
tau=2:(n+2);
t=k;
tau(1)=k+1;
i=0;

curGrayCode=1;
while(i<n+1)
    theCodes(:,curGrayCode)=g(1:n);
    curGrayCode=curGrayCode+1;

    i=tau(1);
    tau(1)=tau(i);
    tau(i)=i+1;

    if(g(i)==1)
        if(t~=0)
            g(t)=1-g(t);
        else
            g(i-1)=1-g(i-1);
        end
        t=t+1;
    else
        if(t~=1)
            g(t-1)=1-g(t-1);
        else
            g(i-1)=1-g(i-1);
        end
        t=t-1;
    end

    g(i)=1-g(i);

    if(t==i-1||t==0)
        t=t+1;
    else
        t=t-g(i-1);
        tau(i-1)=tau(1);

        if(t==0)
            tau(1)=i-1;
        else
            tau(1)=t+1;
        end
    end
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:
function varargout = Biodata(varargin)
% BIODATA M-file for Biodata.fig
%      BIODATA, by itself, creates a new BIODATA or raises the existing
%      singleton*.
%
%      H = BIODATA returns the handle to a new BIODATA or the handle to
%      the existing singleton*.
%
%      BIODATA('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in BIODATA.M with the given input arguments.
%
%      BIODATA('Property','Value',...) creates a new BIODATA or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Biodata_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Biodata_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 Biodata

% Last Modified by GUIDE v2.5 23-Apr-2012 21:40:28

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

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

% Update handles structure
guidata(hObject, handles);

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

% --- Outputs from this function are returned to the command line.
function varargout = Biodata_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 during object creation, after setting all properties.
function axes8_CreateFcn(hObject, eventdata, handles)
% hObject    handle to axes8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: place code in OpeningFcn to populate axes8
axes (hObject)
imshow ('Biodata.jpg')

author: Sable

repo: mcbench-benchmarks


text:
function eect2k = eect2000 (date1, date2)

%  equation of the equinoxes complementary terms, consistent with
%  iau 2000 resolutions.

%  annexe to iers conventions 2000, chapter 5

%  capitaine, n., wallace, p.t., & mccarthy, d.d. (2003). astron. &
%  astrophys. 406, pp. 1135-1149, table 3.
%  iers conventions (2010), chapter 5, p. 60, table 5.2e.
%  (table 5.2e presented in the printed publication is a truncated
%  series. the full series, which is used in novas, is available on
%  the iers conventions center website in file tab5.2e.txt.)
%  ftp://tai.bipm.org/iers/conv2010/chapter5/

%  input

%   date1, date2 = tt date (jd = date1 + date2)

%  output

%   eect2k = complementary terms (radians)

%  this revision:  2002 november 13
%                  references updated 2010 november 26

% ported from NOVAS 3.1

%%%%%%%%%%%%%%%%%%%%%%%

% 2 pi

d2pi = 6.283185307179586476925287d0;

% arc seconds to radians

das2r = 4.848136811095359935899141d-6;

% reference epoch (j2000), jd

dj0 = 2451545.0d0;

% days per julian century

djc = 36525.0d0;

%  -----------------------------------------
%  the series for the ee complementary terms
%  -----------------------------------------

%  number of terms in the series

ne0 = 33;

ne1 = 1;

%  argument coefficients for t^0

ke0 = [0,  0,  0,  0,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0;
    0,  0,  0,  0,  2,  0,  0,  0,  0,  0,  0,  0,  0,  0;
    0,  0,  2, -2,  3,  0,  0,  0,  0,  0,  0,  0,  0,  0;
    0,  0,  2, -2,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0;
    0,  0,  2, -2,  2,  0,  0,  0,  0,  0,  0,  0,  0,  0;
    0,  0,  2,  0,  3,  0,  0,  0,  0,  0,  0,  0,  0,  0;
    0,  0,  2,  0,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0;
    0,  0,  0,  0,  3,  0,  0,  0,  0,  0,  0,  0,  0,  0;
    0,  1,  0,  0,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0;
    0,  1,  0,  0, -1,  0,  0,  0,  0,  0,  0,  0,  0,  0;
    1,  0,  0,  0, -1,  0,  0,  0,  0,  0,  0,  0,  0,  0;
    1,  0,  0,  0,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0;
    0,  1,  2, -2,  3,  0,  0,  0,  0,  0,  0,  0,  0,  0;
    0,  1,  2, -2,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0;
    0,  0,  4, -4,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0;
    0,  0,  1, -1,  1,  0, -8, 12,  0,  0,  0,  0,  0,  0;
    0,  0,  2,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0;
    0,  0,  2,  0,  2,  0,  0,  0,  0,  0,  0,  0,  0,  0;
    1,  0,  2,  0,  3,  0,  0,  0,  0,  0,  0,  0,  0,  0;
    1,  0,  2,  0,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0;
    0,  0,  2, -2,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0;
    0,  1, -2,  2, -3,  0,  0,  0,  0,  0,  0,  0,  0,  0;
    0,  1, -2,  2, -1,  0,  0,  0,  0,  0,  0,  0,  0,  0;
    0,  0,  0,  0,  0,  0,  8,-13,  0,  0,  0,  0,  0, -1;
    0,  0,  0,  2,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0;
    2,  0, -2,  0, -1,  0,  0,  0,  0,  0,  0,  0,  0,  0;
    1,  0,  0, -2,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0;
    0,  1,  2, -2,  2,  0,  0,  0,  0,  0,  0,  0,  0,  0;
    1,  0,  0, -2, -1,  0,  0,  0,  0,  0,  0,  0,  0,  0;
    0,  0,  4, -2,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0;
    0,  0,  2, -2,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0;
    1,  0, -2,  0, -3,  0,  0,  0,  0,  0,  0,  0,  0,  0;
    1,  0, -2,  0, -1,  0,  0,  0,  0,  0,  0,  0,  0,  0;];

% transpose

ke0 = ke0';

%  argument coefficients for t^1

ke1 = [0,  0,  0,  0,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0];

% transpose

ke1 = ke1';

%  sine and cosine coefficients for t^0

se0 = [+2640.96d-6,          -0.39d-6;
    +63.52d-6,          -0.02d-6;
    +11.75d-6,          +0.01d-6;
    +11.21d-6,          +0.01d-6;
    -4.55d-6,          +0.00d-6;
    +2.02d-6,          +0.00d-6;
    +1.98d-6,          +0.00d-6;
    -1.72d-6,          +0.00d-6;
    -1.41d-6,          -0.01d-6;
    -1.26d-6,          -0.01d-6;
    -0.63d-6,          +0.00d-6;
    -0.63d-6,          +0.00d-6;
    +0.46d-6,          +0.00d-6;
    +0.45d-6,          +0.00d-6;
    +0.36d-6,          +0.00d-6;
    -0.24d-6,          -0.12d-6;
    +0.32d-6,          +0.00d-6;
    +0.28d-6,          +0.00d-6;
    +0.27d-6,          +0.00d-6;
    +0.26d-6,          +0.00d-6;
    -0.21d-6,          +0.00d-6;
    +0.19d-6,          +0.00d-6;
    +0.18d-6,          +0.00d-6;
    -0.10d-6,          +0.05d-6;
    +0.15d-6,          +0.00d-6;
    -0.14d-6,          +0.00d-6;
    +0.14d-6,          +0.00d-6;
    -0.14d-6,          +0.00d-6;
    +0.14d-6,          +0.00d-6;
    +0.13d-6,          +0.00d-6;
    -0.11d-6,          +0.00d-6;
    +0.11d-6,          +0.00d-6;
    +0.11d-6,          +0.00d-6;];

se0 = se0';

%  sine and cosine coefficients for t^1

se1 = [-0.87d-6, +0.00d-6];

% transpose

se1 = se1';

%  interval between fundamental epoch j2000.0 and current date (jc)

t = ((date1 - dj0) + date2) / djc;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  fundamental arguments (from iers conventions 2000)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%  mean anomaly of the moon

fa(1) = anmp ((485868.249036d0 + (715923.2178d0 + (31.8792d0 ...
    + (0.051635d0 + (-0.00024470d0) * t) * t) * t) * t) * das2r ...
    + mod (1325.0d0 * t, 1.0d0) * d2pi);

%  mean anomaly of the sun

fa(2) = anmp ((1287104.793048d0 + (1292581.0481d0 + (-0.5532d0 ...
    + (+0.000136d0 + (-0.00001149d0) * t) * t) * t) * t) * das2r ...
    + mod (99.0d0 * t, 1.0d0) * d2pi);

%  mean longitude of the moon minus mean longitude of the ascending
%  node of the moon

fa(3) = anmp (( 335779.526232d0 + (295262.8478d0 + (-12.7512d0 ...
    + (-0.001037d0 + (0.00000417d0) * t) * t) * t) * t) * das2r ...
    + mod (1342d0 * t, 1d0) * d2pi);

%  mean elongation of the moon from the sun

fa(4) = anmp ((1072260.703692d0 + (1105601.2090d0 + (-6.3706d0 ...
    + (0.006593d0 + (-0.00003169d0) * t) * t) * t) * t) * das2r ...
    + mod (1236d0 * t, 1d0) * d2pi);

%  mean longitude of the ascending node of the moon

fa(5) = anmp ((450160.398036d0 + (-482890.5431d0 + (7.4722d0 ...
    + (0.007702d0 + (-0.00005939d0) * t) * t) * t) * t) * das2r ...
    + mod (-5.0d0 * t, 1.0d0) * d2pi);

fa(6) = anmp (4.402608842d0 + 2608.7903141574d0 * t);
fa(7) = anmp (3.176146697d0 + 1021.3285546211d0 * t);
fa(8) = anmp (1.753470314d0 +  628.3075849991d0 * t);
fa(9) = anmp (6.203480913d0 +  334.0612426700d0 * t);
fa(10) = anmp (0.599546497d0 +   52.9690962641d0 * t);
fa(11) = anmp (0.874016757d0 +   21.3299104960d0 * t);
fa(12) = anmp (5.481293872d0 +    7.4781598567d0 * t);
fa(13) = anmp (5.311886287d0 +    3.8133035638d0 * t);
fa(14) =      (0.024381750d0 +    0.00000538691d0 * t) * t;

%  evaluate the ee complementary terms

s0 = 0.0d0;

s1 = 0.0d0;

for i = ne0: -1: 1

    a = 0.0d0;

    for j = 1:14

        a = a + ke0(j, i) * fa(j);

    end

    s0 = s0 + (se0(1, i) * sin(a) + se0(2, i) * cos(a));

end

for i = ne1: -1: 1

    a = 0.0d0;

    for j = 1:14

        a = a + ke1(j, i) * fa(j);

    end

    s1 = s1 + (se1(1, i) * sin(a) + se1(2, i) * cos(a));

end

eect2k = (s0 + s1 * t) * das2r;

author: goGPS-Project


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Author: Eugenio Alcala Baselga
% Date: 02/06/2018
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

classdef automatic_kinematic_control

    properties(Constant)
        V_vec           = [1 18];  % Case of State FEedback LPV kinematic control
%         V_vec           = [2 18]; % Case of MPC kinematic control

        Theta_err_vec   = [deg2rad(-5) deg2rad(5)];
        W_vec           = [-1.417 1.417];
        gamma = 0.01;
        Q               = [ 2    0     0;
                            0    3     0;
                            0    0    20];
        R               = [ 0.5   0;
                            0   0.001];
    end

    methods
    end

end


text:
function scale = GetScalingFactors(modelname)
%
% function scale = GetScalingFactors(modelname)
%
% Returns an array of scaling factors for the parameters of the model
% intended to rescale so that they all have value close to 1.
%
% Note that including the scaling factor for sigma increases the number
% of model variables by 1.
%
% Note that the scaling factor not set for theta and phi
%
% author: Gary Hui Zhang (gary.zhang@ucl.ac.uk)
%

parameterStrings = GetParameterStrings(modelname);

% here the scaling factors do not include the ones for theta and phi
% but include one for the sigma
scale = zeros(1, length(parameterStrings) - 1);

% the scaling factor for sigma is set to 1
scale(end) = 1;

for i=1:length(parameterStrings)
    if (strcmp(parameterStrings(i), 'di') ||...
            strcmp(parameterStrings(i), 'dh') ||...
            strcmp(parameterStrings(i), 'diso'))
        scale(i) = 1E9;
    elseif (strcmp(parameterStrings(i), 'rad'))
        scale(i) = 1E6;
    elseif (strcmp(parameterStrings(i), 'ficvf') ||...
            strcmp(parameterStrings(i), 'fiso') ||...
            strcmp(parameterStrings(i), 'irfrac') ||...
            strcmp(parameterStrings(i), 'psi') ||...
            strcmp(parameterStrings(i), 'b0') ||...
            strcmp(parameterStrings(i), 't1'))
        scale(i) = 1;
    elseif (strcmp(parameterStrings(i), 'kappa') ||...
            strcmp(parameterStrings(i), 'beta'))
        scale(i) = 0.1;
    end
end

author: qMRLab

repo: qMRLab

save_path: github-repos/MATLAB/qMRLab-qMRLab