comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » More problems with Curvefit
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
More problems with Curvefit [message #35619] Mon, 30 June 2003 07:35 Go to previous message
heather.williams is currently offline  heather.williams
Messages: 3
Registered: July 2002
Junior Member
Good afternoon, everyone. I'm having some problems using Curvefit (in
IDL 5.4) to fit my data. I've reviewed the messages which have already
been posted on this subject, and had a good look at the MPCURVEFIT
substitute, but am no wiser.

My code looks like this:

PRO data_fit

;Define the vectors of tabulated:

F18_x = FLTARR(12) & F18_x(0) = 9.055227833
F18_x(1) = 9.908886278 & F18_x(2) = 11.86860889
F18_x(3) = 13.281685 & F18_x(4) = 16.69834393
F18_x(5) = 19.52864256 & F18_x(6) = 23.17273836
F18_x(7) = 28.51793219 & F18_x(8) = 31.23624055
F18_x(9) = 33.53401408 & F18_x(10) = 38.12262897
F18_x(11) = 39.15701348
F18_y = FLTARR(12) & F18_y(0) = 0.108598707
F18_y(1) = 0.329883541 & F18_y(2) = 0.504690343
F18_y(3) = 0.685805013 & F18_y(4) = 0.780161321
F18_y(5) = 0.87284238 & F18_y(6) = 0.890067419
F18_y(7) = 0.907523914 & F18_y(8) = 0.98011631
F18_y(9) = 0.943832957 & F18_y(10) = 0.966238284
F18_y(11) = 1

X = FLTARR(12) & X(*) = F18_x(*) - F18_x(0)
Y = FLTARR(12) & Y(*) = F18_y(*) - F18_x(0)

;Define a vector of weights:
W = 1.0
;Provide an initial guess of the function's parameters:
A = [1.0, 1.0]
;Compute the parameters a0 and a1:
yfit = CURVEFIT(X, Y, W, A, SIGMA_A, FUNCTION_NAME = 'fit_funct')
;Print the parameters, which are returned in A:
PRINT, A

END

PRO fit_funct, X, A, F, PDER

F = (1.0 - EXP(-A[0] * X)) + (1.0 - EXP(-A[1]*X))
; PDER's column dimension is equal to the number of
; elements in xi and its row dimension is equal to
; the number of parameters in the function F:
pder = FLTARR(N_ELEMENTS(X), 2)
; Compute the partial derivatives with respect to
; a0 and place in the first row of PDER:
pder[*, 0] = A[0] * EXP(-A[0] * X)
pder[*, 1] = A[1] * EXP(-A[1] * X)

END


Which looks alright, if not particularly elegant, to me. However, when
I run it, I get this error message (which relates to the line
beginning y_fit =) :

% Operands of matrix multiply have incompatible dimensions: <FLOAT
Array[2, 12]>, <FLOAT Array[1, 2]>.
% Error occurred at: CURVEFIT 269
O:\Rsi\Idl54\lib\curvefit.pro
% DATA_FIT 21 H:\PhD
IDL\Progs\data_fit.pro
% $MAIN$

How do I avoid this error and get the fit to work?

Thanks for your help,
Heather Williams

PhD Student, Manchester PET Centre
Manchester, UK
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Format Code Question
Next Topic: IDL from crontab going defunct?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 14:52:44 PDT 2025

Total time taken to generate the page: 0.00438 seconds