help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: regarding leasqr


From: preeti gaikwad
Subject: Re: regarding leasqr
Date: Tue, 5 Jul 2011 09:02:42 +0200

thanks Olaf for ur post....yes u were right I should use p(6) non zero. but I tried with the same and find no difference.
my function is
___________________________________________________________________________________________________
function F = conv_fnc(x,p) % Diffusive time-decay profile
if nargin~=2
   error('This function is waiting for 2 arguments')
end
nr=length(x);
g0=0;%num
g1=1000;%num
g3=0.000000003;%in s
g2 = p(1); %  or t0 in s
tabs=0.000000002; %in sec
L=0.005;  %%% IN METER
n=1.01;
A = p(6);
D0=p(2);
tloc=p(3);
a=p(4);
m=p(5);
c=p(7);
               
        D=(D0.*tloc.^(a))./(tloc.^(m).+x.^(m)).^(a./m);
               
%gaussian function; pulse
z=g0+g1.*exp(-((x-g2)./g3).^ 2);
%exponential decay
 
s=A.*exp(-x./tabs).*(D./D0).^2.*exp(-(pi*pi).*(D.*x)./L.^2);
%% model function: convolution
F =conv(z,s)+c;
F=F(1:nr);
___________________________________________________________________________
and the main program is
nr=240;
nc=320;
t=linspace(0,1.97694 ,nr);
lambda=linspace(479.4845 ,557.5614, nc); %          

tri=load( "fivemm_2ns_60g.dat"); %                    

%% other configuration (default values):
tolerance = .00001;
max_iterations = 1000;
weights = ones (1, nr);
dp = [.01; .0001; .0001; .0001; .0001; 0.0001; 0.0001]; % bidirectional numeric gradient stepsize
dFdp = 'dfdp'; % function for gradient (numerical)
  %initial values and bounds
pin = [0.5 25 0.000000005 1 7 1000 1000]; % g2, Do in m squre per sec,  tloc, a, m, and A, c

options.bounds=[0 10; 0 50; 0 0.0000001; 0 2; 0 10; 0 10000; 0 10000];
y=zeros(nr,1);
  %--lambda fit loop ------------------------------------------------------
 for i=1:nc% i is the LAMBDA VARIABLE
    y=y+tri(:,i);
    end
    %% start leasqr, be sure that 'verbose' is not set
        global verbose; verbose = false;
        [f, p] = leasqr(t, y, pin,'conv_fnc', tolerance, max_iterations, weights, dp, dFdp, options);
        %t0=P(1);
        D0 = p(2);
        %off = p(2);
        tloc= p(3);
        a=p(4);
        m=p(5);
        A=p(6);
         c=p(7);
           fit = f;
figure(10)
i=100;
    h1=semilogy(t,y,'o')    
    hold on
    h2=semilogy(t,f,'r')
thanks for ur help.........



On 4 July 2011 15:36, Olaf Till <address@hidden> wrote:
On Mon, Jul 04, 2011 at 02:48:09PM +0200, preeti gaikwad wrote:
> Hello all,
>
>               I am the new user in fitting please help me to solve my query.
> I am using leasqr to estimate parameters from the experimental data.
>
> my fuction is
>
> s=A.*exp(-x./tabs).*(D./D0).^2.*exp(-(pi*pi).*(D.*x)./L.^2);
>
> where D is
>
> D=(D0.*tloc.^(a))./(tloc.^(m).+x.^(m)).^(a./m);
>
> I would like to calculate
>
>
>  A = p(6);% constant value
>
> D0=p(2);
>
> tloc=p(3);
>
> a=p(4);
>
> m=p(5);
>  Using the leasqr
>
> [f, p] = leasqr(t, y, pin,'conv_fnc', tolerance, max_iterations, weights,
> dp, dFdp, options);
>
> unfortunately i am getting value whatever is my pin
>
> like my pin is
>
> pin = [0.5 25 0.000000005 1 7 1000 0]
>
>
> and for all value of x I have straight line like but my experimental data is
> exponential decreasing function.
>
>
> and the defined fuction is s also exponential decay function. My quest is
> why leasqr is not giving the new calculated value from the fun s???? THANKS
> FOR YOUR HELP in advance.
>
>
> regards P

I can't be sure to understand what is the problem. And if I were, I
could not reproduce it. You should tell us the complete code of the
definition of your function (including "tabs" and "L"; you could just
paste the contents of the function file) and the contents of all
variables passed to leasqr (including tolerance and so on).

Having said that, if indeed p(6) is constant (I can't see it from the
information you give), since your model function seems to multiply its
value by p(6), and p(6)==0 according to your pin, the resulting values
of the model function of corse are always 0.

Olaf



--
preeti gaikwad

reply via email to

[Prev in Thread] Current Thread [Next in Thread]