help-octave
[Top][All Lists]
Advanced

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

regarding leasqr function


From: preeti gaikwad
Subject: regarding leasqr function
Date: Fri, 6 May 2011 16:37:51 +0200


Hello I am very new user of qt octave and trying to fit my function to the experimental data......in my data I have transmission at given wavelength and for given thickness..... for 10 thcikness i want to calculate absorption length and transport mean free path.....using mention input i want to fit my data in photonic ohms law
I have some doubts
1. HOW to call the function in qt octave?
2. I am getting the error that leasqr is not defined....
3. its an itarative program so its not asking for input and then some comment that "fit" is not defined.....

Here I am sending you my code for ohms law and function....
OHMS_law
....................................................................................................................................................................................................................................................................
load("-ascii", "/home/gaikwad/Bureau/for octave/FinalTiO2.dat", "")  %put here the file name you want to load
fname =  FinalTiO2;
lambda = fname(:,1) ;
nr=size(fname,1);
nc=size(fname,2)-1;
T=fname(:,2:1+nc);
% thickness vector
L = [72 80 91 100 107 108 150 181 223 265 268 350];
x = L-50; %um thickness correction due to the air bubble
y=1./T(1,:);
%% initial values:
pin = [0.5 250];% ls;la
options.bounds=[0 5;100 500];
%% other configuration (default values):
tolerance = .0001;
max_iterations = 100;
weights = ones (1, nc);
dp = [.001; .001]; % bidirectional numeric gradient stepsize
dFdp = 'dfdp'; % function for gradient (numerical)
 
figure(100)
contourf(L,lambda,log(abs(1./T)))
ylabel('Wavelength [nm]','FontSize',14)
title(' 1/ Total transmission - log scale','FontSize',14)
xlabel(' Thickness L [um]','FontSize',14)
colormap("default")
caxis([0 6])
colorbar

 % data fitting
lmax=length(lambda);
lmin = 1;
lambda = lambda([lmin:lmax]);

%--lambda fit loop ------------------------------------------------------

for i=lmin:lmax % i is the LAMBDA VARIABLE
   
%all points are used
    y=1./T(i,:);
    %% start leasqr, be sure that 'verbose' is not set
    global verbose; verbose = 1;
    [f, p] = leasqr(x, y, pin,trans_fnc.m , tolerance, max_iterations, weights, dp, dFdp, options.bounds);
    ls(i) = p(1);
    la(i) = p(2);
    fit(i,:) = f;
         
end %--end of lambda fit loop ---------------------------------------------

%% -plot and save
figure(31)
    plot(lambda, ls,'.')
    xlabel(' Wavelength [nm]','FontSize',14)
    ylabel('Transport m.f.p. [um]','FontSize',14)
    title(' Scattering length from the fit ','FontSize',14)
    % axis([0 1200 1 1.5 ])
   
figure(32)
    plot(lambda, la,'r.')
    xlabel(' Wavelength [nm]','FontSize',14)
    ylabel('Transport m.f.p. [um]','FontSize',14)
    title(' Absorption length from the fit ','FontSize',14)
    % axis([0 1200 1 1.5 ])
   
   
    %-Ohm's law plot-------------------------------------------------------

    figure(1)
    plot(x,1./T(166,:),'*')
    hold on
    plot(x,1./T(195,:),'ro')
    plot(x,fit(166,:),'b')
    plot(x,fit(195,:),'-r')
    hold off
    xlabel(' Thickness L [um]','FontSize',14)
    ylabel('1/Transmission [1/%]','FontSize',14)
    title(' 1/ Total transmission - lambda cut','FontSize',14)
    %axis([0 1600 1 100 ])
    legend('lambda = 824 nm','lambda = 876 nm','FontSize',14)
 ____________________________________________________________________________________________________________________________________________________
Function  

  function F = trans_fnc(x,p) % Diffusive time-decay profile
if nargin~=2
   error('This function is waiting for 2 arguments')
end
   
ls = p(1); % in um
la = p(2);% in um
offset = 0.0;
c=0.3; %speed of light in um/fs
n1 = 2.1;                       % average refractive index
n2 = 1;
R  = 0.52; % average reflection on the interface from PRA 44, 3948 (1991)
%Rz = (n1-n2)/((n1+n2)^2);
z0 = (2/3)*ls*(1+R)/(1-R);
ze = (la/2)*log((1+(1/la)*z0)/(1-(1/la)*z0));
zp = ze;
%% model function:
F=1.0./( (la/ze)*sinh((zp+ze)/la)*sinh(ze/la)./sinh(((x+offset)+2*ze)/la)); % inverse transmittance   
________________________________________________________________
thanks a lot in advance for your help

REgards,

--
preeti

reply via email to

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