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

Home » Public Forums » archive » Re: Print 2 arrays side by side in one file
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: Print 2 arrays side by side in one file [message #68670] Thu, 19 November 2009 06:01 Go to next message
Maarten[1] is currently offline  Maarten[1]
Messages: 176
Registered: November 2005
Senior Member
On Nov 19, 2:34 pm, ali mozafari <a.mozafari1...@googlemail.com>
wrote:

> I need to print 2 arrays side by side in one file I put something like
> this:
>
> openw,1,'FINAL.dat'
> printf,2, x,y, format='(3f14)'
> close,2
>
> Unfortunately in output file it prints first x array and then y like
> this:
> x
> y
> will you please help me to fix this?

This may do what you want:
z = transpose(reform([x,y], n_elements(x), 2))
openw, 2,'FINAL.dat'
printf, 2, z, format='(2f14)'
close,2

Maarten
Re: Print 2 arrays side by side in one file [message #68671 is a reply to message #68670] Thu, 19 November 2009 05:59 Go to previous messageGo to next message
Carsten Lechte is currently offline  Carsten Lechte
Messages: 124
Registered: August 2006
Senior Member
ali mozafari wrote:
> I need to print 2 arrays side by side in one file I put something like

You could try this:

IDL> print, transpose( [ [1,2,3,4], [7,8,9,10]])
1 7
2 8
3 9
4 10

chl
Re: Print 2 arrays side by side in one file [message #68768 is a reply to message #68670] Thu, 19 November 2009 06:31 Go to previous message
a.mozafari1211 is currently offline  a.mozafari1211
Messages: 16
Registered: February 2009
Junior Member
On Nov 19, 6:01 am, Maarten <maarten.sn...@knmi.nl> wrote:
> On Nov 19, 2:34 pm, ali mozafari <a.mozafari1...@googlemail.com>
> wrote:
>
>> I need to print 2 arrays side by side in one file I put something like
>> this:
>
>> openw,1,'FINAL.dat'
>> printf,2, x,y, format='(3f14)'
>> close,2
>
>> Unfortunately in output file it prints first x array and then y like
>> this:
>> x
>> y
>> will you please help me to fix this?
>
> This may do what you want:
> z = transpose(reform([x,y], n_elements(x), 2))
> openw, 2,'FINAL.dat'
> printf, 2, z, format='(2f14)'
> close,2
>
> Maarten

Thanks. it works very well.
Cheers
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Some more symbols to plot some data
Next Topic: Re: Migrate away from idl?

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

Current Time: Wed Oct 08 11:40:57 PDT 2025

Total time taken to generate the page: 0.00484 seconds