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

Home » Public Forums » archive » matrices with different size
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
matrices with different size [message #42151] Thu, 13 January 2005 08:21 Go to next message
ikverveelmijdood is currently offline  ikverveelmijdood
Messages: 1
Registered: January 2005
Junior Member
Hi,
my problem is the following: I have a dataset with a strong sinusoidal
component. However, its period and height are not constant. What I
exactly want is to split-up the data in different parts, and put them
into a matrix. Is this possible in IDL (and how?) to generate a
matrix, filled with vectors that have a different length? I know that
in Matlab "cell arrays" can be used.
Best regards,
Veerle
Re: matrices with different size [message #42247 is a reply to message #42151] Thu, 13 January 2005 14:30 Go to previous messageGo to next message
Chris Lee is currently offline  Chris Lee
Messages: 101
Registered: August 2003
Senior Member
In article <3374f20e.0501130821.41623a00@posting.google.com>, "V.S."
<ikverveelmijdood@hotmail.com> wrote:


> Hi,
> my problem is the following: I have a dataset with a strong sinusoidal
> component. However, its period and height are not constant. What I
> exactly want is to split-up the data in different parts, and put them
> into a matrix. Is this possible in IDL (and how?) to generate a matrix,
> filled with vectors that have a different length? I know that in Matlab
> "cell arrays" can be used.
> Best regards,
> Veerle

I have to ask why you want to split the dataset into (presumably) single
wave period and not something use Fourier or Wavelet analysis on the
full data but anyway....You could use pointers.
e.g

a=ptrarr(10)
a[0]=ptr_new(fltarr(100))
a[1]=ptr_new(fltarr(20))
a[2]=ptr_new(lonarr(10))
..
plot, *a[0] ;etc

Chris.
Re: Matrices [message #82878 is a reply to message #42151] Mon, 21 January 2013 12:06 Go to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
On 1/21/13 11:39 AM, fd_luni@mail.com wrote:
> Τη Δευτέρα, 21 Ιανουαρίου 2013 5:21:13 μ.μ. UTC+2, ο χρήστης Matthew Argall έγραψε:
>>> myNbyFour [:,0] = [1, 2, 3, 4]
>>
>>
>>
>> Sorry, this should be
>>
>>
>>
>> myNbyFour[0,*] = [1, 2, 3, 4]
>
> Thank you very much for your answers. Maybe I didn't explain very well what I actually wanna do before. Let's say I have four arrays A,B,C,D and E with 100 elements each. Now, I want to create an array which includes the elements of A,B,C and D (100 by 4 matrix).In other words, I want to write the four arrays A,B,C,D into 1 matrix,and a matrix which includes only the elements of E (vertically) so 100 by 1 matrix.
>

IDL> ABCD = [[A], [B], [C], [D]]
IDL> help, ABCD
<Expression> FLOAT = Array[100, 4]
IDL> Ecolumn = reform(E, n_elements(E), 1)
IDL> help, Ecolumn
ECOLUMN FLOAT = Array[100, 1]

Of course, Ecolumn will lose the trailing single dimension if you do
anything with it... but many (but not all!) things you might think of
doing with it won't care.

-Jeremy.
Re: Matrices [message #82883 is a reply to message #42151] Mon, 21 January 2013 09:55 Go to previous message
fd_luni is currently offline  fd_luni
Messages: 66
Registered: January 2013
Member
Thank you very much for your answers. Maybe I didn't explain very well what I actually wanna do before. Let's say I have four arrays A,B,C,D and E with 100 elements each. Now, I want to create an array which includes the elements of A,B,C and D (100 by 4 matrix).In other words, I want to write the four arrays A,B,C,D into 1 matrix,and a matrix which includes only the elements of E(vertically) so 100 by 1 matrix.

P.S. an N by 4 matrix has N rows and 4 colunmns!!
Re: Matrices [message #82884 is a reply to message #42151] Mon, 21 January 2013 09:39 Go to previous message
fd_luni is currently offline  fd_luni
Messages: 66
Registered: January 2013
Member
Τη Δευτέρα, 21 Ιανουαρίου 2013 5:21:13 μ.μ. UTC+2, ο χρήστης Matthew Argall έγραψε:
>> myNbyFour [:,0] = [1, 2, 3, 4]
>
>
>
> Sorry, this should be
>
>
>
> myNbyFour[0,*] = [1, 2, 3, 4]

Thank you very much for your answers. Maybe I didn't explain very well what I actually wanna do before. Let's say I have four arrays A,B,C,D and E with 100 elements each. Now, I want to create an array which includes the elements of A,B,C and D (100 by 4 matrix).In other words, I want to write the four arrays A,B,C,D into 1 matrix,and a matrix which includes only the elements of E (vertically) so 100 by 1 matrix.
Re: Matrices [message #82885 is a reply to message #42151] Mon, 21 January 2013 07:21 Go to previous message
Matthew Argall is currently offline  Matthew Argall
Messages: 286
Registered: October 2011
Senior Member
> myNbyFour [:,0] = [1, 2, 3, 4]

Sorry, this should be

myNbyFour[0,*] = [1, 2, 3, 4]
Re: Matrices [message #82886 is a reply to message #42151] Mon, 21 January 2013 07:20 Go to previous message
Matthew Argall is currently offline  Matthew Argall
Messages: 286
Registered: October 2011
Senior Member
> I want to create an N by 4 (Nx4)matrix and an N by 1 (Nx1)matrix with my own elements. Does anyone know how to do it?

Helder's first example is good, but also, look into

Look into the lonarr(), intarr(), fltarr(), dblarr(), etc. functions in addition to make_array(). If you want a floating point array

N = 10
myNbyFour = fltarr(N, 4)
myNbyOne = fltarr(N, 1)

Then you can assign values to each element like

myNbyFour[0,0] = 5

or

myNbyFour [:,0] = [1, 2, 3, 4]

etc
Re: Matrices [message #82887 is a reply to message #42151] Mon, 21 January 2013 06:48 Go to previous message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
On Monday, January 21, 2013 3:32:42 PM UTC+1, fd_...@mail.com wrote:
> Hello!
>
>
>
> I just start using IDL and I have one simple question about matrices.
>
>
>
> I want to create an N by 4 (Nx4)matrix and an N by 1 (Nx1)matrix with my own elements. Does anyone know how to do it?

Hi,
this is not normally the way people make things, however here is a command line option:
MyFiveByFourMatrix = [[0,4,8,12,16],[1,5,9,13,17],[2,6,10,14,18],[3,7,11,15,19]]
To check, just type:
help, MyFiveByFourMatrix

But generally you would like to use something like:
N=10
MyFiveByFourMatrix = Make_array(N,4,/INTEGER) ; Makes a 10x4 matrix

If you want to do a Nx1 matrix, use either:
N_by_One_Matrix = [0,1,2,3,4,5]
or
N_by_One_Matrix = Make_array(N,1,/INTEGER)

The above actually generates an array of N elements. If you really want a Nx1, then you should do the following:
N_by_One_Matrix = reform([0,1,2,3,4,5], 6,1)
or
N_by_One_Matrix = reform(Make_array(N,/INTEGER),N,1)

Hope it helps.

Cheers,
Helder
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: LSODE status=-1
Next Topic: Imposing inverse fft to be real

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

Current Time: Thu Oct 09 06:50:25 PDT 2025

Total time taken to generate the page: 1.68189 seconds