Generated Code

The following is matlab code generated by the CellML API from this CellML file. (Back to language selection)

The raw code is available.

function [VOI, STATES, ALGEBRAIC, CONSTANTS] = mainFunction()
    % This is the "main function".  In Matlab, things work best if you rename this function to match the filename.
   [VOI, STATES, ALGEBRAIC, CONSTANTS] = solveModel();
end

function [algebraicVariableCount] = getAlgebraicVariableCount() 
    % Used later when setting a global variable with the number of algebraic variables.
    % Note: This is not the "main method".  
    algebraicVariableCount =31;
end
% There are a total of 6 entries in each of the rate and state variable arrays.
% There are a total of 23 entries in the constant variable array.
%

function [VOI, STATES, ALGEBRAIC, CONSTANTS] = solveModel()
    % Create ALGEBRAIC of correct size
    global algebraicVariableCount;  algebraicVariableCount = getAlgebraicVariableCount();
    % Initialise constants and state variables
    [INIT_STATES, CONSTANTS] = initConsts;

    % Set timespan to solve over 
    tspan = [0, 10];

    % Set numerical accuracy options for ODE solver
    options = odeset('RelTol', 1e-06, 'AbsTol', 1e-06, 'MaxStep', 1);

    % Solve model with ODE solver
    [VOI, STATES] = ode15s(@(VOI, STATES)computeRates(VOI, STATES, CONSTANTS), tspan, INIT_STATES, options);

    % Compute algebraic variables
    [RATES, ALGEBRAIC] = computeRates(VOI, STATES, CONSTANTS);
    ALGEBRAIC = computeAlgebraic(ALGEBRAIC, CONSTANTS, STATES, VOI);

    % Plot state variables against variable of integration
    [LEGEND_STATES, LEGEND_ALGEBRAIC, LEGEND_VOI, LEGEND_CONSTANTS] = createLegends();
    figure();
    plot(VOI, STATES);
    xlabel(LEGEND_VOI);
    l = legend(LEGEND_STATES);
    set(l,'Interpreter','none');
end

function [LEGEND_STATES, LEGEND_ALGEBRAIC, LEGEND_VOI, LEGEND_CONSTANTS] = createLegends()
    LEGEND_STATES = ''; LEGEND_ALGEBRAIC = ''; LEGEND_VOI = ''; LEGEND_CONSTANTS = '';
    LEGEND_VOI = strpad('time in component environment (second)');
    LEGEND_CONSTANTS(:,1) = strpad('C_m in component environment (fF)');
    LEGEND_STATES(:,1) = strpad('q_Ca_o in component environment (fmol)');
    LEGEND_STATES(:,2) = strpad('q_Ca_i in component environment (fmol)');
    LEGEND_STATES(:,3) = strpad('q_s00_TCC in component environment (fmol)');
    LEGEND_STATES(:,4) = strpad('q_s10_TCC in component environment (fmol)');
    LEGEND_STATES(:,5) = strpad('q_s01_TCC in component environment (fmol)');
    LEGEND_STATES(:,6) = strpad('q_s11_TCC in component environment (fmol)');
    LEGEND_ALGEBRAIC(:,3) = strpad('q_mem in component environment (fC)');
    LEGEND_ALGEBRAIC(:,2) = strpad('V_mem in component environment (volt)');
    LEGEND_CONSTANTS(:,2) = strpad('R in component environment (J_per_K_per_mol)');
    LEGEND_CONSTANTS(:,3) = strpad('T in component environment (kelvin)');
    LEGEND_CONSTANTS(:,4) = strpad('F in component environment (C_per_mol)');
    LEGEND_ALGEBRAIC(:,23) = strpad('v_TCC in component TCC (fmol_per_sec)');
    LEGEND_ALGEBRAIC(:,29) = strpad('I_mem_TCC in component TCC (fA)');
    LEGEND_CONSTANTS(:,23) = strpad('I_stim in component environment (fA)');
    LEGEND_CONSTANTS(:,5) = strpad('stimPeriod in component environment (second)');
    LEGEND_CONSTANTS(:,6) = strpad('stimDuration in component environment (second)');
    LEGEND_ALGEBRAIC(:,1) = strpad('tPeriod in component environment (second)');
    LEGEND_CONSTANTS(:,7) = strpad('kappa_TCC in component TCC_parameters (fmol_per_sec)');
    LEGEND_CONSTANTS(:,8) = strpad('kappa_R1_TCC in component TCC_parameters (fmol_per_sec)');
    LEGEND_CONSTANTS(:,9) = strpad('kappa_R2_TCC in component TCC_parameters (fmol_per_sec)');
    LEGEND_CONSTANTS(:,10) = strpad('kappa_R3_TCC in component TCC_parameters (fmol_per_sec)');
    LEGEND_CONSTANTS(:,11) = strpad('kappa_R4_TCC in component TCC_parameters (fmol_per_sec)');
    LEGEND_CONSTANTS(:,12) = strpad('K_Ca_i in component TCC_parameters (per_fmol)');
    LEGEND_CONSTANTS(:,13) = strpad('K_Ca_o in component TCC_parameters (per_fmol)');
    LEGEND_CONSTANTS(:,14) = strpad('K_S00_TCC in component TCC_parameters (per_fmol)');
    LEGEND_CONSTANTS(:,15) = strpad('K_S10_TCC in component TCC_parameters (per_fmol)');
    LEGEND_CONSTANTS(:,16) = strpad('K_S01_TCC in component TCC_parameters (per_fmol)');
    LEGEND_CONSTANTS(:,17) = strpad('K_S11_TCC in component TCC_parameters (per_fmol)');
    LEGEND_CONSTANTS(:,18) = strpad('zCa in component TCC_parameters (dimensionless)');
    LEGEND_CONSTANTS(:,19) = strpad('z_df in component TCC_parameters (dimensionless)');
    LEGEND_CONSTANTS(:,20) = strpad('z_ff in component TCC_parameters (dimensionless)');
    LEGEND_CONSTANTS(:,21) = strpad('z_dr in component TCC_parameters (dimensionless)');
    LEGEND_CONSTANTS(:,22) = strpad('z_fr in component TCC_parameters (dimensionless)');
    LEGEND_ALGEBRAIC(:,4) = strpad('u_Ca_i in component TCC (J_per_mol)');
    LEGEND_ALGEBRAIC(:,5) = strpad('u_Ca_o in component TCC (J_per_mol)');
    LEGEND_ALGEBRAIC(:,6) = strpad('V_mem in component TCC (J_per_C)');
    LEGEND_ALGEBRAIC(:,7) = strpad('Am_TCC in component TCC (J_per_mol)');
    LEGEND_ALGEBRAIC(:,21) = strpad('Af_Ca in component TCC (J_per_mol)');
    LEGEND_ALGEBRAIC(:,22) = strpad('Ar_Ca in component TCC (J_per_mol)');
    LEGEND_ALGEBRAIC(:,19) = strpad('v_s00_TCC in component TCC (fmol_per_sec)');
    LEGEND_ALGEBRAIC(:,30) = strpad('v_s10_TCC in component TCC (fmol_per_sec)');
    LEGEND_ALGEBRAIC(:,27) = strpad('v_s01_TCC in component TCC (fmol_per_sec)');
    LEGEND_ALGEBRAIC(:,31) = strpad('v_s11_TCC in component TCC (fmol_per_sec)');
    LEGEND_ALGEBRAIC(:,14) = strpad('v_R1_TCC in component TCC (fmol_per_sec)');
    LEGEND_ALGEBRAIC(:,26) = strpad('v_R2_TCC in component TCC (fmol_per_sec)');
    LEGEND_ALGEBRAIC(:,18) = strpad('v_R3_TCC in component TCC (fmol_per_sec)');
    LEGEND_ALGEBRAIC(:,28) = strpad('v_R4_TCC in component TCC (fmol_per_sec)');
    LEGEND_ALGEBRAIC(:,8) = strpad('mu_s00_TCC in component TCC (J_per_mol)');
    LEGEND_ALGEBRAIC(:,11) = strpad('mu_s10_TCC in component TCC (J_per_mol)');
    LEGEND_ALGEBRAIC(:,15) = strpad('mu_s01_TCC in component TCC (J_per_mol)');
    LEGEND_ALGEBRAIC(:,20) = strpad('mu_s11_TCC in component TCC (J_per_mol)');
    LEGEND_ALGEBRAIC(:,9) = strpad('Af_R1_TCC in component TCC (J_per_mol)');
    LEGEND_ALGEBRAIC(:,12) = strpad('Ar_R1_TCC in component TCC (J_per_mol)');
    LEGEND_ALGEBRAIC(:,16) = strpad('Af_R2_TCC in component TCC (J_per_mol)');
    LEGEND_ALGEBRAIC(:,24) = strpad('Ar_R2_TCC in component TCC (J_per_mol)');
    LEGEND_ALGEBRAIC(:,10) = strpad('Af_R3_TCC in component TCC (J_per_mol)');
    LEGEND_ALGEBRAIC(:,17) = strpad('Ar_R3_TCC in component TCC (J_per_mol)');
    LEGEND_ALGEBRAIC(:,13) = strpad('Af_R4_TCC in component TCC (J_per_mol)');
    LEGEND_ALGEBRAIC(:,25) = strpad('Ar_R4_TCC in component TCC (J_per_mol)');
    LEGEND_RATES(:,2) = strpad('d/dt q_Ca_i in component environment (fmol)');
    LEGEND_RATES(:,1) = strpad('d/dt q_Ca_o in component environment (fmol)');
    LEGEND_RATES(:,3) = strpad('d/dt q_s00_TCC in component environment (fmol)');
    LEGEND_RATES(:,4) = strpad('d/dt q_s10_TCC in component environment (fmol)');
    LEGEND_RATES(:,5) = strpad('d/dt q_s01_TCC in component environment (fmol)');
    LEGEND_RATES(:,6) = strpad('d/dt q_s11_TCC in component environment (fmol)');
    LEGEND_STATES  = LEGEND_STATES';
    LEGEND_ALGEBRAIC = LEGEND_ALGEBRAIC';
    LEGEND_RATES = LEGEND_RATES';
    LEGEND_CONSTANTS = LEGEND_CONSTANTS';
end

function [STATES, CONSTANTS] = initConsts()
    VOI = 0; CONSTANTS = []; STATES = []; ALGEBRAIC = [];
    CONSTANTS(:,1) = 60000;
    STATES(:,1) = 0.04653;
    STATES(:,2) = 0.000001551;
    STATES(:,3) = 3.653271338425772e-07;
    STATES(:,4) = 1e-16;
    STATES(:,5) = 1e-16;
    STATES(:,6) = 1e-16;
    CONSTANTS(:,2) = 8.31;
    CONSTANTS(:,3) = 310;
    CONSTANTS(:,4) = 96500;
    CONSTANTS(:,5) = 1;
    CONSTANTS(:,6) = 0.0001;
    CONSTANTS(:,7) = 11414.6;
    CONSTANTS(:,8) = 1266.14;
    CONSTANTS(:,9) = 4.33488;
    CONSTANTS(:,10) = 1.34962;
    CONSTANTS(:,11) = 7.44777;
    CONSTANTS(:,12) = 28.7976;
    CONSTANTS(:,13) = 211.182;
    CONSTANTS(:,14) = 2.10659;
    CONSTANTS(:,15) = 0.381738;
    CONSTANTS(:,16) = 615.294;
    CONSTANTS(:,17) = 111.498;
    CONSTANTS(:,18) = 2;
    CONSTANTS(:,19) = 0.876568910405296;
    CONSTANTS(:,20) = -0.576510778245838;
    CONSTANTS(:,21) = -0.872117216889333;
    CONSTANTS(:,22) = 1.73582739545622;
    CONSTANTS(:,23) = 0.00000;
    if (isempty(STATES)), warning('Initial values for states not set');, end
end

function [RATES, ALGEBRAIC] = computeRates(VOI, STATES, CONSTANTS)
    global algebraicVariableCount;
    statesSize = size(STATES);
    statesColumnCount = statesSize(2);
    if ( statesColumnCount == 1)
        STATES = STATES';
        ALGEBRAIC = zeros(1, algebraicVariableCount);
        utilOnes = 1;
    else
        statesRowCount = statesSize(1);
        ALGEBRAIC = zeros(statesRowCount, algebraicVariableCount);
        RATES = zeros(statesRowCount, statesColumnCount);
        utilOnes = ones(statesRowCount, 1);
    end
    ALGEBRAIC(:,2) = piecewise({VOI>=0.00000&VOI<0.400000,  - 0.0900000 , VOI>1.10000&VOI<2.10000,  - 0.0600000 , VOI>2.20000&VOI<3.10000, 0.0400000 , VOI>3.50000,  - 0.0900000 },  - 0.0800000);
    ALGEBRAIC(:,3) =  ALGEBRAIC(:,2).*CONSTANTS(:,1);
    ALGEBRAIC(:,6) = ALGEBRAIC(:,3)./CONSTANTS(:,1);
    ALGEBRAIC(:,8) =  CONSTANTS(:,2).*CONSTANTS(:,3).*log( CONSTANTS(:,14).*STATES(:,3));
    ALGEBRAIC(:,9) = ALGEBRAIC(:,8)+ CONSTANTS(:,19).*CONSTANTS(:,4).*ALGEBRAIC(:,6);
    ALGEBRAIC(:,11) =  CONSTANTS(:,2).*CONSTANTS(:,3).*log( CONSTANTS(:,15).*STATES(:,4));
    ALGEBRAIC(:,12) = ALGEBRAIC(:,11)+ CONSTANTS(:,21).*CONSTANTS(:,4).*ALGEBRAIC(:,6);
    ALGEBRAIC(:,14) =  CONSTANTS(:,8).*(exp(ALGEBRAIC(:,9)./( CONSTANTS(:,2).*CONSTANTS(:,3))) - exp(ALGEBRAIC(:,12)./( CONSTANTS(:,2).*CONSTANTS(:,3))));
    ALGEBRAIC(:,10) = ALGEBRAIC(:,8)+ CONSTANTS(:,20).*CONSTANTS(:,4).*ALGEBRAIC(:,6);
    ALGEBRAIC(:,15) =  CONSTANTS(:,2).*CONSTANTS(:,3).*log( CONSTANTS(:,16).*STATES(:,5));
    ALGEBRAIC(:,17) = ALGEBRAIC(:,15)+ CONSTANTS(:,22).*CONSTANTS(:,4).*ALGEBRAIC(:,6);
    ALGEBRAIC(:,18) =  CONSTANTS(:,10).*(exp(ALGEBRAIC(:,10)./( CONSTANTS(:,2).*CONSTANTS(:,3))) - exp(ALGEBRAIC(:,17)./( CONSTANTS(:,2).*CONSTANTS(:,3))));
    ALGEBRAIC(:,19) =  - ALGEBRAIC(:,14) - ALGEBRAIC(:,18);
    RATES(:,3) = ALGEBRAIC(:,19);
    ALGEBRAIC(:,7) =  CONSTANTS(:,18).*CONSTANTS(:,4).*ALGEBRAIC(:,6);
    ALGEBRAIC(:,4) =  CONSTANTS(:,2).*CONSTANTS(:,3).*log( CONSTANTS(:,12).*STATES(:,2));
    ALGEBRAIC(:,20) =  CONSTANTS(:,2).*CONSTANTS(:,3).*log( CONSTANTS(:,17).*STATES(:,6));
    ALGEBRAIC(:,21) = ALGEBRAIC(:,20)+ALGEBRAIC(:,4)+ALGEBRAIC(:,7);
    ALGEBRAIC(:,5) =  CONSTANTS(:,2).*CONSTANTS(:,3).*log( CONSTANTS(:,13).*STATES(:,1));
    ALGEBRAIC(:,22) = ALGEBRAIC(:,20)+ALGEBRAIC(:,5);
    ALGEBRAIC(:,23) = piecewise({ALGEBRAIC(:,7)==0.00000,  CONSTANTS(:,7).*(exp(ALGEBRAIC(:,21)./( CONSTANTS(:,2).*CONSTANTS(:,3))) - exp(ALGEBRAIC(:,22)./( CONSTANTS(:,2).*CONSTANTS(:,3)))) },  ((( CONSTANTS(:,7).*ALGEBRAIC(:,7))./( CONSTANTS(:,2).*CONSTANTS(:,3)))./(exp(ALGEBRAIC(:,7)./( CONSTANTS(:,2).*CONSTANTS(:,3))) - 1.00000)).*(exp(ALGEBRAIC(:,21)./( CONSTANTS(:,2).*CONSTANTS(:,3))) - exp(ALGEBRAIC(:,22)./( CONSTANTS(:,2).*CONSTANTS(:,3)))));
    RATES(:,2) =  - ALGEBRAIC(:,23);
    RATES(:,1) = ALGEBRAIC(:,23);
    ALGEBRAIC(:,16) = ALGEBRAIC(:,15)+ CONSTANTS(:,19).*CONSTANTS(:,4).*ALGEBRAIC(:,6);
    ALGEBRAIC(:,24) = ALGEBRAIC(:,20)+ CONSTANTS(:,21).*CONSTANTS(:,4).*ALGEBRAIC(:,6);
    ALGEBRAIC(:,26) =  CONSTANTS(:,9).*(exp(ALGEBRAIC(:,16)./( CONSTANTS(:,2).*CONSTANTS(:,3))) - exp(ALGEBRAIC(:,24)./( CONSTANTS(:,2).*CONSTANTS(:,3))));
    ALGEBRAIC(:,27) = ALGEBRAIC(:,18) - ALGEBRAIC(:,26);
    RATES(:,5) = ALGEBRAIC(:,27);
    ALGEBRAIC(:,13) = ALGEBRAIC(:,11)+ CONSTANTS(:,20).*CONSTANTS(:,4).*ALGEBRAIC(:,6);
    ALGEBRAIC(:,25) = ALGEBRAIC(:,20)+ CONSTANTS(:,22).*CONSTANTS(:,4).*ALGEBRAIC(:,6);
    ALGEBRAIC(:,28) =  CONSTANTS(:,11).*(exp(ALGEBRAIC(:,13)./( CONSTANTS(:,2).*CONSTANTS(:,3))) - exp(ALGEBRAIC(:,25)./( CONSTANTS(:,2).*CONSTANTS(:,3))));
    ALGEBRAIC(:,30) = ALGEBRAIC(:,14) - ALGEBRAIC(:,28);
    RATES(:,4) = ALGEBRAIC(:,30);
    ALGEBRAIC(:,31) = ALGEBRAIC(:,26)+ALGEBRAIC(:,28);
    RATES(:,6) = ALGEBRAIC(:,31);
   RATES = RATES';
end

% Calculate algebraic variables
function ALGEBRAIC = computeAlgebraic(ALGEBRAIC, CONSTANTS, STATES, VOI)
    statesSize = size(STATES);
    statesColumnCount = statesSize(2);
    if ( statesColumnCount == 1)
        STATES = STATES';
        utilOnes = 1;
    else
        statesRowCount = statesSize(1);
        utilOnes = ones(statesRowCount, 1);
    end
    ALGEBRAIC(:,2) = piecewise({VOI>=0.00000&VOI<0.400000,  - 0.0900000 , VOI>1.10000&VOI<2.10000,  - 0.0600000 , VOI>2.20000&VOI<3.10000, 0.0400000 , VOI>3.50000,  - 0.0900000 },  - 0.0800000);
    ALGEBRAIC(:,3) =  ALGEBRAIC(:,2).*CONSTANTS(:,1);
    ALGEBRAIC(:,6) = ALGEBRAIC(:,3)./CONSTANTS(:,1);
    ALGEBRAIC(:,8) =  CONSTANTS(:,2).*CONSTANTS(:,3).*log( CONSTANTS(:,14).*STATES(:,3));
    ALGEBRAIC(:,9) = ALGEBRAIC(:,8)+ CONSTANTS(:,19).*CONSTANTS(:,4).*ALGEBRAIC(:,6);
    ALGEBRAIC(:,11) =  CONSTANTS(:,2).*CONSTANTS(:,3).*log( CONSTANTS(:,15).*STATES(:,4));
    ALGEBRAIC(:,12) = ALGEBRAIC(:,11)+ CONSTANTS(:,21).*CONSTANTS(:,4).*ALGEBRAIC(:,6);
    ALGEBRAIC(:,14) =  CONSTANTS(:,8).*(exp(ALGEBRAIC(:,9)./( CONSTANTS(:,2).*CONSTANTS(:,3))) - exp(ALGEBRAIC(:,12)./( CONSTANTS(:,2).*CONSTANTS(:,3))));
    ALGEBRAIC(:,10) = ALGEBRAIC(:,8)+ CONSTANTS(:,20).*CONSTANTS(:,4).*ALGEBRAIC(:,6);
    ALGEBRAIC(:,15) =  CONSTANTS(:,2).*CONSTANTS(:,3).*log( CONSTANTS(:,16).*STATES(:,5));
    ALGEBRAIC(:,17) = ALGEBRAIC(:,15)+ CONSTANTS(:,22).*CONSTANTS(:,4).*ALGEBRAIC(:,6);
    ALGEBRAIC(:,18) =  CONSTANTS(:,10).*(exp(ALGEBRAIC(:,10)./( CONSTANTS(:,2).*CONSTANTS(:,3))) - exp(ALGEBRAIC(:,17)./( CONSTANTS(:,2).*CONSTANTS(:,3))));
    ALGEBRAIC(:,19) =  - ALGEBRAIC(:,14) - ALGEBRAIC(:,18);
    ALGEBRAIC(:,7) =  CONSTANTS(:,18).*CONSTANTS(:,4).*ALGEBRAIC(:,6);
    ALGEBRAIC(:,4) =  CONSTANTS(:,2).*CONSTANTS(:,3).*log( CONSTANTS(:,12).*STATES(:,2));
    ALGEBRAIC(:,20) =  CONSTANTS(:,2).*CONSTANTS(:,3).*log( CONSTANTS(:,17).*STATES(:,6));
    ALGEBRAIC(:,21) = ALGEBRAIC(:,20)+ALGEBRAIC(:,4)+ALGEBRAIC(:,7);
    ALGEBRAIC(:,5) =  CONSTANTS(:,2).*CONSTANTS(:,3).*log( CONSTANTS(:,13).*STATES(:,1));
    ALGEBRAIC(:,22) = ALGEBRAIC(:,20)+ALGEBRAIC(:,5);
    ALGEBRAIC(:,23) = piecewise({ALGEBRAIC(:,7)==0.00000,  CONSTANTS(:,7).*(exp(ALGEBRAIC(:,21)./( CONSTANTS(:,2).*CONSTANTS(:,3))) - exp(ALGEBRAIC(:,22)./( CONSTANTS(:,2).*CONSTANTS(:,3)))) },  ((( CONSTANTS(:,7).*ALGEBRAIC(:,7))./( CONSTANTS(:,2).*CONSTANTS(:,3)))./(exp(ALGEBRAIC(:,7)./( CONSTANTS(:,2).*CONSTANTS(:,3))) - 1.00000)).*(exp(ALGEBRAIC(:,21)./( CONSTANTS(:,2).*CONSTANTS(:,3))) - exp(ALGEBRAIC(:,22)./( CONSTANTS(:,2).*CONSTANTS(:,3)))));
    ALGEBRAIC(:,16) = ALGEBRAIC(:,15)+ CONSTANTS(:,19).*CONSTANTS(:,4).*ALGEBRAIC(:,6);
    ALGEBRAIC(:,24) = ALGEBRAIC(:,20)+ CONSTANTS(:,21).*CONSTANTS(:,4).*ALGEBRAIC(:,6);
    ALGEBRAIC(:,26) =  CONSTANTS(:,9).*(exp(ALGEBRAIC(:,16)./( CONSTANTS(:,2).*CONSTANTS(:,3))) - exp(ALGEBRAIC(:,24)./( CONSTANTS(:,2).*CONSTANTS(:,3))));
    ALGEBRAIC(:,27) = ALGEBRAIC(:,18) - ALGEBRAIC(:,26);
    ALGEBRAIC(:,13) = ALGEBRAIC(:,11)+ CONSTANTS(:,20).*CONSTANTS(:,4).*ALGEBRAIC(:,6);
    ALGEBRAIC(:,25) = ALGEBRAIC(:,20)+ CONSTANTS(:,22).*CONSTANTS(:,4).*ALGEBRAIC(:,6);
    ALGEBRAIC(:,28) =  CONSTANTS(:,11).*(exp(ALGEBRAIC(:,13)./( CONSTANTS(:,2).*CONSTANTS(:,3))) - exp(ALGEBRAIC(:,25)./( CONSTANTS(:,2).*CONSTANTS(:,3))));
    ALGEBRAIC(:,30) = ALGEBRAIC(:,14) - ALGEBRAIC(:,28);
    ALGEBRAIC(:,31) = ALGEBRAIC(:,26)+ALGEBRAIC(:,28);
    ALGEBRAIC(:,1) = VOI -  floor(VOI./CONSTANTS(:,5)).*CONSTANTS(:,5);
    ALGEBRAIC(:,29) =  CONSTANTS(:,4).*(  - CONSTANTS(:,18).*ALGEBRAIC(:,23)+ ALGEBRAIC(:,14).*(CONSTANTS(:,21) - CONSTANTS(:,19))+ ALGEBRAIC(:,26).*(CONSTANTS(:,21) - CONSTANTS(:,19))+ ALGEBRAIC(:,18).*(CONSTANTS(:,22) - CONSTANTS(:,20))+ ALGEBRAIC(:,28).*(CONSTANTS(:,22) - CONSTANTS(:,20)));
end

% Compute result of a piecewise function
function x = piecewise(cases, default)
    set = [0];
    for i = 1:2:length(cases)
        if (length(cases{i+1}) == 1)
            x(cases{i} & ~set,:) = cases{i+1};
        else
            x(cases{i} & ~set,:) = cases{i+1}(cases{i} & ~set);
        end
        set = set | cases{i};
        if(set), break, end
    end
    if (length(default) == 1)
        x(~set,:) = default;
    else
        x(~set,:) = default(~set);
    end
end

% Pad out or shorten strings to a set length
function strout = strpad(strin)
    req_length = 160;
    insize = size(strin,2);
    if insize > req_length
        strout = strin(1:req_length);
    else
        strout = [strin, blanks(req_length - insize)];
    end
end

Source
Derived from workspace CaT protein knowledge page at changeset b7e7f45db3c7.
Collaboration
To begin collaborating on this work, please use your git client and issue this command:
License
The terms of use/license for this work is unspecified.