Location: cellLib @ c05a1749b300 / Scripts / copyComp.m

Author:
WeiweiAi <wai484@aucklanduni.ac.nz>
Date:
2022-05-03 15:18:13+12:00
Desc:
Seperate the setlim for plotExp.py; Update readme.txt
Permanent Source URI:
https://models.cellml.org/workspace/6bc/rawfile/c05a1749b3003de5c15cc530b579b4671106b978/Scripts/copyComp.m

function comp=copyComp(comp,listComp,idx)
cmnames=string(extractfield(comp,'name'));%unique
if length(cmnames)>length(unique(cmnames))
    disp('There are repetitions of component names')
    return
end
def=listComp(:,1);
name=listComp(:,2);
nComp=length(name);
defaultVars=listComp(:,3);
for i=1:nComp
    % default
    icomp=comp(cmnames==def(i));
    icomp.name=name(i);
    if defaultVars=="N"
        % rename some of the aliases for mapping
        nvar=length(icomp.vars(:,idx.var));
        for n=1:nvar
            var= icomp.vars(n,idx.var);
            alias=icomp.vars(n,idx.alias);
            prompt = sprintf('%s-->:%s?',var,alias);
            str = input(prompt,"s");
            if ~isempty(str)
                icomp.vars(n,idx.alias)=str;
            end
        end
    end    
    comp=[comp,icomp];    
end
end