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

Home » Public Forums » archive » Re: Column vector matrix creation from PC image
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Column vector matrix creation from PC image [message #76694] Wed, 22 June 2011 10:05
Wout De Nolf is currently offline  Wout De Nolf
Messages: 194
Registered: October 2008
Senior Member
On Wed, 22 Jun 2011 04:05:14 -0700 (PDT), Lavanya
<lavanya3k@gmail.com> wrote:

> Hi,
>
> I am trying to create a column vector of the form
>
> E = [[ 1, 1, 1, ......1], [e1,e2, .... ep], ......[e1(n),
> e2(n)....ep(n)]]
>
> where the first row values are one, p user input values. Now i need to
> fill the matrix with random values that are obtained from an PC
> image.
>
> Here is the code for reference:
>
> covMatrix = Correlate(image11, /COVARIANCE, /DOUBLE)
> eigenvalues = EIGENQL(covMatrix, EIGENVECTORS=eigenvectors, /DOUBLE)
> Print, eigenvalues
> Print, 'First Component (%): ', eigenvalues[0]/Total(eigenvalues)*100
>
> for i=0, bands-1 do begin;
> pc = eigenvectors ## Transpose(image11)
> pc1[*,*,i] = Reform(pc[*,i], rows, cols)
> ; pc1[*,*,i] = Reform(temporary(pc[*,i]), dims[0], dims[1],4)
> endfor
>
> p = 30
>
> TestMatrix = fltarr(p,p)
> TestMatrix(*,0) = 1
> idx1 = fltarr(1,p)
> ;data = pc(*,p-1)
>
> for i=0,p-1 do begin
> seed = 100L
> idx = floor(randomu(seed,p)) + 1
> TestMatrix(1:p,*) = pc(idx,*) ; error at
> this place
> idx1(i) = idx;
> endfor
>
> Finally, i need to construct TestMatrix


Some comments:

1. Use square brackets for array subscripts.

2. Why are you calculating pc within the loop? Should pc1 be pc? Also
check the function MATRIX_MULTIPLY to avoid ## with TRANSPOSE.
> for i=0, bands-1 do begin;
> pc = eigenvectors ## Transpose(image11)
> pc1[*,*,i] = Reform(pc[*,i], rows, cols)
> endfor

3. The reason why this fails is because TestMatrix has p columns, so
subscripting [1:p,*] won't work.
> TestMatrix(1:p,*) = pc(idx,*) ; error at this place

4. Define the seed outside the loop, otherwise you always get the same
"random" numbers.

5. To encourage people to answer your question, give a "minimal
working example" that we just have to copy&run. Filling in the gaps is
just too enjoying. Problems are often solved just by making a MWE.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Sort a HASH
Next Topic: polyfill on postscript: hairy with hairlines

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

Current Time: Wed Oct 08 13:56:35 PDT 2025

Total time taken to generate the page: 0.00636 seconds