function sintrend_abs(varargin)
%x=-10:0.01:10;
%y=x*0.001+sin(x);
if (length(varargin)==1)
    fullpath='';
    outfile='';
    paramsfile='';
    niter=varargin{1};
else
    if (length(varargin)==3)
        fullpath=varargin{1};
        niter=varargin{3};
        outfile=varargin{2}
        paramsfile=strrep(outfile,'.txt','.mat');
    else
        niter=3;
        fullpath='';
        outfile='';
        paramsfile='';    
    end
end
if length(fullpath)==0
    [file,path]=uigetfile('*.txt','Укажите входной файл');
    fullpath=strcat(path,file);
end
y=dlmread(fullpath);
n=length(y);
x=1:n;
size(y,1);
size(y,2);
if (size(y,2)>size(y,1))
    y=transpose(y);
end
if (size(x,2)>size(x,1))
    x=transpose(x);
end
%if (min(y)<0)
%    y=ones(n,1)*(min(y)+100)+y;
%end
y=log(y);
remains=y;
masparams=[];
%niter=5;
for i=1:niter
    [y1,remains,params]=dosintrend_abs(x,remains,0);
    masparams=[masparams,params];
end;
figure;
plot(remains);
if length(outfile)==0
    [file,path]=uiputfile('*.txt','Сохраните ряд остатков для прогноза');
    outfile=strcat(path,file);
end
dlmwrite(outfile,remains,'\n');
if length(paramsfile)==0
    [file,path]=uiputfile('*.mat','Сохраните коэффициенты модели');
    paramsfile=strcat(path,file);
end
save(paramsfile);
end
                                                                                                                                                                                                                                                                                                                                                                                       5