%%%%%%%%%
%%%%%%%%% Find the increments of the discrete points for the varying
%%%%%%%%% parameters. 
%%%%%%%%%

chngparwidth=[];
chngparini=[];
chngparend=[];
chngparlogwidth=[];
chngparlogini=[];
chngparlogend=[];
for i=1:length(chngpars)
    chngparini(i)=min(chngparranges(i,:));
    chngparend(i)=max(chngparranges(i,:));
    chngparwidth(i)=(chngparend(i)-chngparini(i))/max([1,chngparpoints(i)-1]);
end


parind=1;
par1pts=chngparini(parind)+chngparwidth(parind)*((1:chngparpoints(parind))-1);

parind=2;
par2pts=chngparini(parind)+chngparwidth(parind)*((1:chngparpoints(parind))-1);

parind=3;
par3pts=chngparini(parind)+chngparwidth(parind)*((1:chngparpoints(parind))-1);


idrand=strcmp('yes', randparpts);
if idrand(1)==1
    parind=1;
    par1pts=par1pts+chngparwidth(parind)*(rand(1,chngparpoints(parind))-.5);
    par1pts(1)=chngparini(parind)+chngparwidth(parind)*rand(1)/2;
    par1pts(end)=chngparend(parind)-chngparwidth(parind)*rand(1)/2;
end
if idrand(2)==1
    parind=2;
    par2pts=par2pts+chngparwidth(parind)*(rand(1,chngparpoints(parind))-.5);
    par2pts(1)=chngparini(parind)+chngparwidth(parind)*rand(1)/2;
    par2pts(end)=chngparend(parind)-chngparwidth(parind)*rand(1)/2;
end
if idrand(3)==1
    parind=3;
    par3pts=par3pts+chngparwidth(parind)*(rand(1,chngparpoints(parind))-.5);
    par3pts(1)=chngparini(parind)+chngparwidth(parind)*rand(1)/2;
    par3pts(end)=chngparend(parind)-chngparwidth(parind)*rand(1)/2;
end

par1plotpts=par1pts;
par2plotpts=par2pts;
par3plotpts=par3pts;

id=strcmp('yes', logscales);
if id(1)==1
    parind=1;
    chngparlogini=log(chngparini(parind))/log(10);
    chngparlogend=log(chngparend(parind))/log(10);
    chngparlogwidth=(chngparlogend-chngparlogini)/max([1,chngparpoints(parind)-1]);
    par1plotpts=chngparlogini+chngparlogwidth*((1:chngparpoints(parind))-1);
    par1pts=10.^par1plotpts;
    if idrand(1)==1
        par1plotpts=par1plotpts+chngparlogwidth*(rand(1,chngparpoints(parind))-.5);
        par1plotpts(1)=chngparlogini+chngparlogwidth*rand(1)/2;
        par1plotpts(end)=chngparlogend-chngparlogwidth*rand(1)/2;;
        par1pts=10.^par1plotpts;
    end
end
if id(2)==1
    parind=2;
    chngparlogini=log(chngparini(parind))/log(10);
    chngparlogend=log(chngparend(parind))/log(10);
    chngparlogwidth=(chngparlogend-chngparlogini)/max([1,chngparpoints(parind)-1]);
    par2plotpts=chngparlogini+chngparlogwidth*((1:chngparpoints(parind))-1);
    par2pts=10.^par2plotpts;
    if idrand(2)==1
        par2plotpts=par2plotpts+chngparlogwidth*(rand(1,chngparpoints(parind))-.5);
        par2plotpts(1)=chngparlogini+chngparlogwidth*rand(1)/2;
        par2plotpts(end)=chngparlogend-chngparlogwidth*rand(1)/2;;
        par2pts=10.^par2plotpts;
    end
end
if id(3)==1
    parind=3;
    chngparlogini=log(chngparini(parind))/log(10);
    chngparlogend=log(chngparend(parind))/log(10);
    chngparlogwidth=(chngparlogend-chngparlogini)/max([1,chngparpoints(parind)-1]);
    par3plotpts=chngparlogini+chngparlogwidth*((1:chngparpoints(parind))-1);
    par3pts=10.^par3plotpts;
    if idrand(3)==1
        par3plotpts=par3plotpts+chngparlogwidth*(rand(1,chngparpoints(parind))-.5);
        par3plotpts(1)=chngparlogini+chngparlogwidth*rand(1)/2;
        par3plotpts(end)=chngparlogend-chngparlogwidth*rand(1)/2;;
        par3pts=10.^par3plotpts;
    end
end


%%%%%%%%%
%%%%%%%%%
%%%%%%%%%

