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

Home » Public Forums » archive » How to manipulate vectors by the index
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
How to manipulate vectors by the index [message #93916] Wed, 23 November 2016 13:35 Go to previous message
Edson Filho is currently offline  Edson Filho
Messages: 4
Registered: November 2016
Junior Member
Hey guys, I'm a beginner here in Idl and at the moment, I have to create a program and I'm trying to organize the vectors by the index. I mean, the way I was doing it before, I was overlapping the values, so I want to change it. Here is the problem:

The program is about astrophysics and I got describe the behavior of some stars using monte carlo simulation. Here is the way I Declare my vector. The first collumn reffers to time, and the other one is the number of stars.

VarM2=fltarr((nt+nt2),E02)
VarM3=fltarr((nt+nt2),E03)
VarM4=fltarr((nt+nt2),E04)
VarM5=fltarr((nt+nt2),E05)
VarM8=fltarr((nt+nt2),E08)
VarM10=fltarr((nt+nt2),E10)

But now I want them to look like following a sequence, instead going from 0 to E02 ( A number of stars), goes form 0 to X (All number of stars) so I tried this :

For B=0,((nt+nt2)-1)do begin
For I=0,E02-1 do VarM2[B,I]=[B,0]
For I=E02,(E02+E03-1)do VarM3[B,I]=[B,0]
For I=E02+E03,(E02+E03+E04-1) do VarM4[B,I]=[B,0]
For I=E02+E03+E04,(E02+E03+E04+E05-1)do VarM5[B,I]=[B,0]
For I=E02+E03+E04+E05,(E02+E03+E04+E05+E08-1) do VarM8[B,I]=[B,0]
For I=E02+E03+E04+E05+E08,(E02+E03+E04+E05+E08+E10-1) do VarM10[B,I]=[B,0]
Endfor

The idea here is like:
Let's say E02 is 5, and E03 is 10, then VarM2 goes from 0 to 5, then VarM3 goes from 5 to 10


And then I got the error:

Attempt to subscript VARM3 with I is out of range.

Then I tried another way, kind of resuming everything in one vector

I declare this vetor with the size NP (Np here means the total number of stars) and (nt+nt2) reffers to time, just like above
VarM=fltarr((nt+nt2),Np)
VarM=[VarM2,VarM3,VarM4,VarM5,VarM8,VarM10]

Then Idl says :
Unable to concatenate variables because the dimensions do not agree: VARM3.


Does anyone know how to solve this? I would be glad if someone could help me!
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: plot dirac delta function?
Next Topic: Plot problem

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

Current Time: Wed Oct 08 11:00:34 PDT 2025

Total time taken to generate the page: 0.00409 seconds