Re: least square matrix [message #43023 is a reply to message #43022] |
Fri, 11 March 2005 05:22  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
"Matthias Demuzere" <Matthias.demuzere@geo.kuleuven.ac.be> writes:
> Hi,
>
> Because my question maybe still a bit unclear, here it is again:
>
> I have a dataset of temperatures taken at hourly steps (k-value, ranging
> from 1-24) for a whole
> month (with i days). Now, I would like to compare each temperature Tk,i with
> every other Tk,j with j the same number of days as in i. I would like to do
> that comparison by least square methods like this
>
> Matrix Ai,j = sum (Tk,i-Tk,j)^2
>
> where the matrix Ai,j is a symmetrical matrix (because i,j are the same
> day).
In IDL notation, this would be:
FOR I = 0, NDAYS-1 DO FOR J = 0, NDAYS-1 DO $
A(I,J) = TOTAL(T(*,I) - T(*,J))
assuming A = FLTARR(NDAYS,NDAYS) and T = FLTARR(24,NDAYS). As an
exercise, you could optimize to only do I GT J.
>
> How can that be done in IDL?
>
> I was thinking of some FOR statements, like this:
>
> FOR i=1, i LE 31, i++ DO BEGIN
> FOR j=1, j LE 31, j++ DO BEGIN
> FOR k=1, k LE 24, k++ DO BEGIN
> function
> ENDFOR
> ENDFOR
> ENDFOR
>
> But this doesn't seems to work really...Any idees, tips,...??
No, it wouldn't work, because it's not IDL. I invite you to read up
on the FOR statement in the documentation, but here are some starters:
* IDL array indices start with 0
* IDL's FOR statement is not C-like
Good luck,
Craig
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|