Location: cellLib @ a7940fcacd45 / Scripts / updateVIO.m

Author:
WeiweiAi <wai484@aucklanduni.ac.nz>
Date:
2023-04-04 15:51:18+12:00
Desc:
Add a steady state example
Permanent Source URI:
https://models.physiomeproject.org/workspace/6bc/rawfile/a7940fcacd455a09bdb7beac0da91eca79cf1adb/Scripts/updateVIO.m

function comp=updateVIO(comp,idx)
cmnames=string(extractfield(comp,'name'));%unique
if length(cmnames)>length(unique(cmnames))
    disp('There are repetitions of component names')
    return
end
ncomp=length(cmnames);
for i=1:ncomp
    vars=comp(i).vars;
    init=vars(:,idx.init);
    pub=vars(:,idx.pub);
    priv=vars(:,idx.priv);
    init = replace(init,"none","");
    pub = replace(pub,"none","");
    priv = replace(priv,"none","");
    firstcomma=strings(length(init),1);
    sedcomma=firstcomma;
    bracket1=firstcomma;
    bracket2=firstcomma;
    
    idxcheck=any([(~(init=="")),(~(pub=="")),(~(priv==""))],2);
    check=find(idxcheck,1);
    if ~isempty(check)
        bracket1(idxcheck,1)="{";
        bracket2(idxcheck,1)="}";
    else
        return
    end
    
    idxcheck=~(init=="");
    check=find(idxcheck,1);
    if ~isempty(check)
        init(idxcheck,1)="init: "+init(idxcheck,1);
        if ~isempty(find(any([(~(pub(idxcheck)=="")),(~(priv(idxcheck)==""))],2),1))
            firstcomma(idxcheck,1)=", ";
        end
    end
    
    idxcheck=~(pub=="");
    check=find(idxcheck,1);
    if ~isempty(check)
        pub(idxcheck,1)="pub: "+pub(idxcheck,1);
    end
    
    idxcheck=~(priv=="");
    check=find(idxcheck,1);
    if ~isempty(check)
        priv(idxcheck,1)="priv: "+priv(idxcheck,1);
        if ~isempty(find(any([(~(pub(idxcheck)=="")),(~(init(idxcheck)==""))],2),1))
            sedcomma(idxcheck,1)=", ";
        end
    end
    
    vio=bracket1+init+firstcomma+pub+sedcomma+priv+bracket2;
    comp(i).vars(:,idx.vio)=vio;
end

end