fname=input('Give name of file with model (i.e. with model;... end;) ','s');

title_table=input('Give name of for saving tex file of table  ','s');


namemodN=regexp(fname,'\.');
if isempty(namemodN)
    namemodN=length(fname)+1;
    fname=strcat(fname,'.mod');
end
   if ~exist(fname,'file');
    disp(['The file <', fname ,'> could not be found in the current directory']);
    return
end 
namemod=fname(1:namemodN-1);
modfile=(textread(fname,'%c','bufsize',1000000,'commentstyle','c++'));
modfile=(strread(modfile','%s','delimiter',';'));
modfile2=modfile;
modfile=char(modfile);
    modstrt= min(strmatch('parameters',(modfile)));
% remove var
varendo=regexprep(strcat( modfile(modstrt,:)),'parameters','');
% replace , with '',
pary= regexprep(varendo,',',' ');
parnames=(strread(pary','%s','delimiter',' '));

for jj=1:size(lgy_,1);
    eval([deblank(lgy_(jj,:)),'_ss=eval(lgy_(jj,:));']);
end

%parnames2=regexprep(parnames,'_','\\_');
[parnames2,indx]= sortrows(regexprep(parnames,'_','\\_'));
parnames=parnames(indx,:);
% eval(['parameters_',namemod]);
parfile=input('Give name of parameters file ==> ','s');
eval(parfile);
npar=size(parnames,1);
dd=[];
kk=[];

for jj=1:npar
    if exist(char(parnames{jj}),'var')
        tmp=num2str(eval(char(parnames{jj})));
    else
        tmp='NA';
    end
    dd=strvcat(dd,['$',char(parnames2{jj}),'$ &=&$ ', tmp,'$']);
    kk=strvcat(kk,'&');
    
end
if (npar/2)-round(npar/2)~=0
    dd=strvcat(dd,'');
    kk=strvcat(kk,'');
%     npar=npar+1;
end

tbtx=tabtex([],'Parameter values',4,[dd(1:npar/2,:),kk(1:npar/2,:),dd(npar/2+1:npar,:)]);

%  tabtex2texpdf(title_table,1,[],tbtx)
 tabtex2texpdf(title_table,0,[],tbtx)