List Archives > 
Maple User Group List Archive > 
Archive by date > 
This Month By Date > 
This Month By Topic
[MUG] plots from Maple
| [MUG] plots from Maple |
|
Author: Malte HENKEL
Posted: Thu, 17 Oct 2002 12:45:45 WETDST
|
>> From: Malte HENKEL "henkel"
Consider the following problem. One has defined a function, say e.g.
f := x-> sin(x*Pi);
and then makes a plot command
plot( f(x), x=0..1);
Fine. Now, HOW do I get the data created by this plot into a text file
and in the form:
1st column with values of x 2nd column with values of f(x)
in order to feed them into a high-quality graphics program ?
(please don't tell me that Maple makes publication-quality plots ...)
I'd like to have something called maple_to_file with does the following:
p1 := plot( f(x), x=0..1):
maple_to_file(p1, `file_name`);
to see the data points generated by plot go in a two-column format into
a text file.
I work with Maple 4, so please avoid exotic things designed for these heavy
higher versions.
Thank you.
Malte Henkel
LPM, Universite Nancy I, France
"henkel"
|
| [MUG] Re: plots from Maple |
|
Author: Maple User Group
Posted: Tue, 22 Oct 2002 17:03:16 -0400
|
>> From: Maple User Group "maple_gr"
| >> From: Malte HENKEL "henkel"
| Now, HOW do I get the data created by this plot into a text file
| and in the form:
| 1st column with values of x 2nd column with values of f(x)
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Fri, 18 Oct 2002 17:20:45 -0700 (PDT)
From: Robert Israel "israel"
To: "maple-list"
Subject: plots from Maple
Maple 4? I hope you mean Maple V Release 4.
If you examine the plot structure created by this command, you find
that the first operand is a CURVES object, whose first operand is the
list of points you want. You can print the points in the format
you want using fprintf. For Release 4, you need to use a name (delimited
by `...`) rather than a string ("...") which you would use in more modern
versions. For example:
> maple_to_file:= proc(P, fname)
local L, pt;
L:= op([1,1],P);
for pt in L do
fprintf(fname, `%f %f\n`, pt[1], pt[2])
od;
fclose(fname);
end;
Robert Israel "israel"
Department of Mathematics http://www.math.ubc.ca/~israel
University of British Columbia
Vancouver, BC, Canada V6T 1Z2
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Sat, 19 Oct 2002 15:03:46 -0800
To: "maple-list"
From: "Mark Fitch" "afmaf"
Subject: plots from Maple
The output of any plot command is a PLOT structure which includes the list
of points. You only need to discard the extra parameters before writing
them to file.
Mark A. Fitch
"The heavens declare the glory of God" Psalm 19
"mfitch"
3321 E. 42nd Ave. Apt. C, Anchorage AK, 99508 USA
(907) 562-2528
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
From: Stanley J Houghton "S.J.Houghton"
Date: Mon, 21 Oct 2002 13:23:01 +0100
To: "henkel" "maple-list"
Subject: plots from Maple
Try someting along the lines of
> f := x-> sin(x*Pi);
> a:=plot(f(x),x=0..1):
> b:=op([1,1],select(has,[op(a)],`CURVES`)):
> fd := open("c:/TestFile.txt",WRITE):
> for i to nops(b) do
> fprintf(fd,"%f,%f\n",b[i][1],b[i][2])
> od:
> close(fd);
I have long since disposed of my Maple 4 but if op([1,1],e) doesn't
work, try op(1,op(1,e)) instead.
For different formatting see the help pages for function fprintf.
Hope it helps
Stan
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Mon, 21 Oct 2002 14:43:07 -0400 (EDT)
From: Carl Devore "devore"
To: "maple-list"
Subject: plots from Maple
maple_to_file:= (p,f)-> writedata(f,op([1,1],p));
|
Previous by date: [MUG] Bug VectorCalculus[Jacobian], Jarausch
Next by date: [MUG] Weird behavior of Maple 6 under XP and NT, Rafal Ablamowicz
Previous thread: [MUG] Plot Size, Joe Rody
Next thread: [MUG] Weird behavior of Maple 6 under XP and NT, Rafal Ablamowicz
|