Re: ListPlot the output of Print
- To: mathgroup at smc.vnet.net
- Subject: [mg4468] Re: ListPlot the output of Print
- From: vvs124 at rsphy1.anu.edu.au (Victoria Steblina)
- Date: Mon, 29 Jul 1996 02:37:22 -0400
- Organization: Optical Sciences Centre, ANU
- Sender: owner-wri-mathgroup at wolfram.com
Mike at utk.edu (Mike) wrote:
>How can I easily render the output of a print statement to ListPlot without
>the cut & paste routine.
>Example:
>Do [ Print[ N[ {x,Sin[x]} ] ] , {x,0,2Pi,Pi/6}]
One way of doing this is to write data in a file after the printing
loop:
In[29]:= file = OpenWrite["datafile"];
Do[Write[file,N[ {x,Sin[x]} ] ] , {x,0,2Pi,Pi/6}]
Close[file];
Check the output "datafile":
In[32]:= !!datafile
{0, 0}
{0.5235987755982988, 0.5}
{1.047197551196598, 0.866025403784439}
{1.570796326794897, 1.}
{2.094395102393195, 0.866025403784439}
{2.617993877991494, 0.5}
{3.141592653589793, 0}
{3.665191429188092, -0.5}
{4.188790204786391, -0.866025403784439}
{4.71238898038469, -1.}
{5.235987755982989, -0.866025403784439}
{5.759586531581287, -0.5}
{6.283185307179587, 0}
Now read the list from the file as a Mathematica expression and
ListPlot it:
In[28]:= ListPlot[ ReadList["datafile", Expression] ]
Out[28]= -Graphics-
Cheers
Vicki
___________________________________________________________________
Victoria Steblina
vvs124 at rsphy1.anu.edu.au
Optical Sciences Centre
Australian National University
==== [MESSAGE SEPARATOR] ====