print data in colunms [message #94214] |
Sun, 26 February 2017 05:27  |
Ali Gamal
Messages: 98 Registered: June 2013
|
Member |
|
|
Hi, all
I have data as three columns, I want to write these data in file as three columns
I used
;*****************************
openw,lun,'modelout.dat',/GET_LUN
restore,file='model.sav',/v
printf,lun,Z,tau,x,FORMAT='(F9.2,4x,F9.2,4x,f9.2)'
free_lun,lun
end
;*****************************
but it print z in two columns, else tau and x
I want it print column 1 is z, column 2 is tau, and column 3 is x, How can I do it ?
|
|
|
Re: print data in colunms [message #94215 is a reply to message #94214] |
Mon, 27 February 2017 02:27  |
Markus Schmassmann
Messages: 129 Registered: April 2016
|
Senior Member |
|
|
On 02/26/2017 02:27 PM, AGW wrote:
> I have data as three columns, I want to write these data in file as three columns
> I used
> ;*****************************
> openw,lun,'modelout.dat',/GET_LUN
> restore,file='model.sav',/v
> printf,lun,Z,tau,x,FORMAT='(F9.2,4x,F9.2,4x,f9.2)'
> free_lun,lun
> end
> ;*****************************
>
> but it print z in two columns, else tau and x
>
> I want it print column 1 is z, column 2 is tau, and column 3 is x, How can I do it ?
There might be a better way, but this should work:
openw,lun,'modelout.dat',/GET_LUN
restore,file='model.sav',/v
n=n_elements(z)
printf,lun,[reform(Z,[1,n]),reform(tau,[1,n]),reform(x,[1,n] )], $
FORMAT='(F9.2,4x,F9.2,4x,f9.2)'
free_lun,lun
I hope this helps, Markus
PS: I don't understand what you mean by
> "but it print z in two columns, else tau and x"
|
|
|