Robert Israel

6522 Reputation

21 Badges

18 years, 186 days
University of British Columbia
Associate Professor Emeritus
North York, Ontario, Canada

MaplePrimes Activity


These are replies submitted by Robert Israel

For example:

> with(plots):
   plotter:= evalf(Array(1..500, i -> [sin(i), sin(sqrt(2)*i),cos(sqrt(2)*i)]));
   display([seq(pointplot3d(plotter(1..10*j),symbol=solidbox),j=0..50)], insequence=true);

The fsolve examples should work just as well with Maple 10.  However, intersectplot was introduced in Maple 11.

The fsolve examples should work just as well with Maple 10.  However, intersectplot was introduced in Maple 11.

As I said, the only reason I did it twice was to get the same Tvalues that odeplot used.  If you specify Tvalues yourself, you can save that step.  For example, for 51 values from t=0 to t=5.5 but more concentrated near t=0 you might try

> Tvalues:= Array([seq(5.5 * j^2/50^2, j=0..50)]);

 

As I said, the only reason I did it twice was to get the same Tvalues that odeplot used.  If you specify Tvalues yourself, you can save that step.  For example, for 51 values from t=0 to t=5.5 but more concentrated near t=0 you might try

> Tvalues:= Array([seq(5.5 * j^2/50^2, j=0..50)]);

 

An algebraic expression involving a function is ok, but for a named function of a function you want to use the composition operator @.  Thus rather than abs(Xp) you should use abs @ Xp, and rather than max(0, Xp) use curry(max, 0) @ Xp.

 

An algebraic expression involving a function is ok, but for a named function of a function you want to use the composition operator @.  Thus rather than abs(Xp) you should use abs @ Xp, and rather than max(0, Xp) use curry(max, 0) @ Xp.

 

Really, I did try it out.  This is in Maple 13.02 under Windows Vista.  The file name was "test", not "test.txt".

Really, I did try it out.  This is in Maple 13.02 under Windows Vista.  The file name was "test", not "test.txt".

Here are the t values for your odeplot:

> Tvalues:= op([1,1],W)[1..-1,1];

You might notice that, as I said before, they are evenly spaced (i*11/98 for i from 0 to 49 in this case), but perhaps, as you claimed, under some circumstances they might have different spacings.  Anyway, this is the only use I'll make of the odeplot.  You could supply any one-dimensional Array of floats, specifying the t values you want for your points.  I'll use dsolve to produce the actual data to be exported.

> S := dsolve({sys, init}, [f1(t),f2(t),f3(t),f4(t)], numeric, 
    output= Tvalues);

And now, as Scott suggested:

> M1 := ArrayTools:-Concatenate(1, S[1, 1], S[2, 1]):
  ExportMatrix("C:\\Test\\Mydata.txt", M1, target = delimited, 
   delimiter = "\t");

which produces a file "c:/Test/Mydata.txt" that looks like this:

t    f1(t)    f2(t)    f3(t)    f4(t)
0.    1.    1.    1.    1.
.112244897959184006    1.05600511921715624    1.00629284745829084    1.01966248539682502    .997228739123765972
...
5.50000000000000000    2.45534985308449726    1.29133033196953728    2.46931625427160740    .739070971882549554
 

 

Here are the t values for your odeplot:

> Tvalues:= op([1,1],W)[1..-1,1];

You might notice that, as I said before, they are evenly spaced (i*11/98 for i from 0 to 49 in this case), but perhaps, as you claimed, under some circumstances they might have different spacings.  Anyway, this is the only use I'll make of the odeplot.  You could supply any one-dimensional Array of floats, specifying the t values you want for your points.  I'll use dsolve to produce the actual data to be exported.

> S := dsolve({sys, init}, [f1(t),f2(t),f3(t),f4(t)], numeric, 
    output= Tvalues);

And now, as Scott suggested:

> M1 := ArrayTools:-Concatenate(1, S[1, 1], S[2, 1]):
  ExportMatrix("C:\\Test\\Mydata.txt", M1, target = delimited, 
   delimiter = "\t");

which produces a file "c:/Test/Mydata.txt" that looks like this:

t    f1(t)    f2(t)    f3(t)    f4(t)
0.    1.    1.    1.    1.
.112244897959184006    1.05600511921715624    1.00629284745829084    1.01966248539682502    .997228739123765972
...
5.50000000000000000    2.45534985308449726    1.29133033196953728    2.46931625427160740    .739070971882549554
 

 

I think you're conflating two quite different things: the type of file and the file extension (i.e. the part of the name after ".").  Certain file extensions are traditionally associated with certain file types, but this is only tradition, and any type of file can have any name (subject only to the operating system's rules on what is allowed as a name).  The operating system can confuse the issue because (depending on your settings) it may hide file extensions for "known file types" when it shows you the folder contents.


The default type of file is text.  Text files sometimes have the extension "txt", but they don't have to.  Sometimes software will automatically supply a default file extension (e.g. if you export a plot as JPEG, it will be given the "jpg" extension).  But writedata does not do this. If you give writedata the file name as data, then a file named "data", not "data.txt", will be produced.  If there is already a directory named "data", that is a conflict.

I think you're conflating two quite different things: the type of file and the file extension (i.e. the part of the name after ".").  Certain file extensions are traditionally associated with certain file types, but this is only tradition, and any type of file can have any name (subject only to the operating system's rules on what is allowed as a name).  The operating system can confuse the issue because (depending on your settings) it may hide file extensions for "known file types" when it shows you the folder contents.


The default type of file is text.  Text files sometimes have the extension "txt", but they don't have to.  Sometimes software will automatically supply a default file extension (e.g. if you export a plot as JPEG, it will be given the "jpg" extension).  But writedata does not do this. If you give writedata the file name as data, then a file named "data", not "data.txt", will be produced.  If there is already a directory named "data", that is a conflict.

You can't do

plot3d(f(t,k) + X2(t,k), t=0..1, k=0..1);

because of premature evaluation (i.e. X2(t,k) doesn't work with symbolic variables t and k), but

plot3d(f + X2, 0 .. 1, 0 .. 1);

(where f is a function of two variables, defined with either -> or unapply) ought to work.  If it doesn't, perhaps let us see your actual code.

You can't do

plot3d(f(t,k) + X2(t,k), t=0..1, k=0..1);

because of premature evaluation (i.e. X2(t,k) doesn't work with symbolic variables t and k), but

plot3d(f + X2, 0 .. 1, 0 .. 1);

(where f is a function of two variables, defined with either -> or unapply) ought to work.  If it doesn't, perhaps let us see your actual code.

First 39 40 41 42 43 44 45 Last Page 41 of 187