acer

32373 Reputation

29 Badges

19 years, 334 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

Yes, it is possible.

acer

Issue the command time[real]() at the start, and assign the result to a name. Then issue it again when the student clicks, and subtract.

acer

solve does not like solve for unevaluated function calls such as your n(SPF) and n(SPH).

So change those to just name like say nSPF and nSPH (or n*SPF and n*SPH if that's what you intended). Both succeed for me in M18.01.

For example,

ineq:=-s*(-n(SPF)*tau+n(SPH))/(tau-1) <= n(SPH):
soln := solve(subs([n(SPF)=nSPF,n(SPH)=nSPH],ineq),nSPH) assuming (tau<1,s>0,s<1,tau>0):
subs([nSPF=n(SPF),nSPH=n(SPH)],soln);

acer

Do not introduce `k` and `x` with floats. Use exact quantities instead. That should get around the discrepancy in Maple 9.5.

restart;
k:=99/100:
m:=1:
x:=(Pi*csc(Pi*(k-m)))/(693/1000*GAMMA(k)*GAMMA(m)):
m1:=MeijerG([[-m],[1-m]],[[0,-m,-m],[k-m]],(-m*k)/snr):
m2:=MeijerG([[-k],[1-k]],[[0,-k,-k],[m-k]],(-m*k)/snr):
c:=x*((((m*k)/snr)^m)*m1-(((m*k)/snr)^k)*m2):
plot([Re(c),Im(c)], snr=-5..10, color=[red,blue]);

In particular, when using those floats in the definitions of `k` and `x` as you had it originally, Maple 9.5 will produce this,

restart;
k:=.99:
m:=1:
x:=(Pi*csc(Pi*(k-m)))/(.693*GAMMA(k)*GAMMA(m)):
m2:=MeijerG([[-k],[1-k]],[[0,-k,-k],[m-k]],(-m*k)/snr):

evalf(eval(m2,snr=5));

                  259.8556695 + 5.313756679 I

exactm2:=convert(m2,rational,exact):
evalf(eval(exactm2,snr=5));

                  6.225950422 - 2.656878345 I

The above may not just be a roundoff issue -- ie. increasing precision might not fix it. You might have to use exact rationals in the arguments to MeijerG.

An alternative workaround for Maple 9.5 could be to convert your `c` (or perhaps just `m2`) expression to exact rational prior to plotting, manipulating expression `c`, or querying `c` at float values of `snr`.

acer

You can do this by first creating a PlotComponent (say, with identity/name of "Plot0") and then pushing a revised plot to it with each new value computed.

In ths attached example I include a `Sleep` call merely to mimic a computation that takes some time.

ticker.mw

acer

If you intend that expression as a multiplication (and not as a compound function application) then insert an explicit multiplication sign (ie. the * on you keyboard) between the two bracketed terms.

(x-4)*(x-4);

                                   2
                            (x - 4) 


(x-4)(x-4);

                          x(x - 4) - 4

Otherwise your input would can get parsed as the function application x(x-a) - a(x-a). That is, the compound operator (x-a) applied to the argument x-a.

Note that 4 applied to x-4 (or pretty much anything) produces a result of 4.

There are some situations, including your example, where an extra blank space between the two bracketed terms would also get interpreted implicitly as a multiplication, if you used 2D Math input mode. In 1D Notation that would produce a parsing error. It can get more confusing still. I suggest getting in the habit of always using an explicit multiplication symbol, to avoid ambiguous situations with implicit multiplication.

acer

One way is to make your absolutely qualified filenames be a concatenation of a base location and some relative paths.

# Uncomment the line you want, and comment out the line you don't want.
#base:="C:/officeplace/location 1/":
#base:="C:/homecomputer/location 2/":

datafileA:=cat(base,"fileA.txt");
datafileB:=cat(base,"../../folderQ/fileB.txt");

readdata(..., datafileA, ...);
...
readdata(..., datafileB, ...);
...

Another way could be to use the currentdir command to set the current working directory.

acer

I see white grid line artefacts using f=1 for that densityplot in Maple 14.00, but they do not appear for me in Maple 14.01.

I am using 64bit Linux.

You might have to contact Maplesoft Tech Support in order to get the point-release update to 14.01, as it's no longer available here I believe.

[edited] You might be able to get the 14.01 update from here.

acer

If I understand what you want then here are two ways to form the block diagonal Matrix result, using repeats of the Matrix Q as the blocks.

restart:                 
Q:=Matrix([[1,2],[3,4]]):
N:=3:                    

LinearAlgebra:-DiagonalMatrix([Q$N]);

                         [1    2    0    0    0    0]
                         [                          ]
                         [3    4    0    0    0    0]
                         [                          ]
                         [0    0    1    2    0    0]
                         [                          ]
                         [0    0    3    4    0    0]
                         [                          ]
                         [0    0    0    0    1    2]
                         [                          ]
                         [0    0    0    0    3    4]

Matrix([Q$N],scan=diagonal);

                         [1    2    0    0    0    0]
                         [                          ]
                         [3    4    0    0    0    0]
                         [                          ]
                         [0    0    1    2    0    0]
                         [                          ]
                         [0    0    3    4    0    0]
                         [                          ]
                         [0    0    0    0    1    2]
                         [                          ]
                         [0    0    0    0    3    4]

acer

There are formatting options for sprintf (and friends) which support this directly. It is fast and lean on memory use. The code below also works in Maple 12.

> M:=Matrix(3,[[1,2,3],[4,5,6],[7,8,9]]);           

                                   [1    2    3]
                                   [           ]
                              M := [4    5    6]
                                   [           ]
                                   [7    8    9]

> parse(sprintf("%{ns}ld\n",M));                     

                                   123456789

See the help-page on topic rtable_printf for details. Within the {} brackets the qualifier `n` suppresses new lines between rows, and the qualifier `s` suppresses any space between entries.

acer

You were close, with your third attempt. Another level of square bracketing specify that things are stacking vertically.

A:=< <1|2|3>,<4|5|6>,<7|8|9>>;

                                    [1  2  3]
                                    [       ]
                               A := [4  5  6]
                                    [       ]
                                    [7  8  9]

Matrix([ [A[1..2,..]], [Vector[row]([91,92,92])], [A[3,..]] ]);

                                [ 1   2   3]
                                [          ]
                                [ 4   5   6]
                                [          ]
                                [91  92  92]
                                [          ]
                                [ 7   8   9]

Note that you forgot square brackets around entries in your Vector call.

acer

You could use a color palette. Eg,

c:=ColorTools:-GetPalette("Niagara"):
plots:-display(seq(plots[odeplot](sol[i],t=0..10,color=c[i]),i=1..nops([sol])));

See also the pre-made palettes listed by the ColorTools[PaletteNames] command.

One thing I like about a color palette such as `c` is that its membership widens on demand. When you reference c[i] for higher value of `i` then a new shade is generated which matches the tonal "feel" of the previous colors while trying to stay well spaced w.r.t. the previous colors. (The color computation sometimes gets sluggish, but values are remembered.) You can also create your own palette, and install one for automatic use by `plot`, etc.

acer

Focusing on your package usage question, and leaving aside that this particular example might be done directly under assumptions on z, could you both load the (table-based) inttrans package and call its member laplace with the longer, qualified syntax so as to have a visual cue as to what is being called by your code source? Granted, that does not give a cue as to what the call in the output may be. So much for table-based packages...

restart;

with(inttrans):

f:=t->piecewise(t<0,0,t>=0 and t<z,t,t>z,z):
r:=convert(f(t),Heaviside):
r:=inttrans[laplace](r,t,s);

                                                                                 z
    r := laplace(t Heaviside(z - t), t, s) - z laplace(Heaviside(z - t), t, s) + -
                                                                                 s
eval(r,z=0.5);

                0.5000000000 (2. - 1. exp(-0.5000000000 s) (s + 2.))
                ----------------------------------------------------
                                         2.                         
                                        s                           

                                                   1.      
                 0.5 (1. - 1. exp(-0.5000000000 s))     0.5
               - ------------------------------------ + ---
                                  1.                     s 
                                 s                         

You might even try loading only a subset of members of such a table-based package. For example, replacing with(inttrans) above with with(inttrans,laplace). That might help if you also wish to keep your global namespace less altered.

Not directly related to your example but somewhat on-topic is the following. In some circumstances it is simpler to call module-based package members with the P:-m syntax, rather than the safer form of the indexed syntax such as P[':-m']. Perhaps see the final examples for the table-based student package, on the colondash help-page.

acer

Like your previous Question, this is about Array plots, GUI Tables and plot sizing. Please see my Answer there.

BodePlot happens to return an Array plot (a _PLOTARRAY structure). But the issues relate to all Array plots, and not just to BodePlot per se.

In this example you have forced one part of the size to 300, but then complain that the aspect ratio is not right.

You might instead try something like these. The first forces one dimenstion only. The second forces the percentage of GUI width (assuming Table properties match). And the third forces only the aspect ratio.

DS:-BodePlot(sys,range=0.1..100,size=[default,300]);

DS:-BodePlot(sys,range=0.1..100,size=[0.4,300]);

DS:-BodePlot(sys,range=0.1..100,size=[default,0.7]);

You haven't said what aspect ratio you're hoping for.

acer

That framed "window" is a GUI Table. If you right-click inside it you should see an item "Table" in the second section of the pop-up context-menu. Under "Table" look for menu item "Properties...". Select that choice. This brings up a pop-up in which you can toggle off the display of the exterior and interior borders of the Table.

You can also resize the Table by dragging the exterior or interior borders with the mouse. You might wish to experiment with that alongside, say,

DS:-BodePlot(sys,output=horizontalplot,size=[300,300]);

or

DS:-BodePlot(sys,output=horizontalplot,size=[0.3,300]);

The choice for "Table Size Mode" in the popup for context-menu item Table->Properties affects how the Table and its plot entries re-size (or not) to match any manual resizing of the full Maple GUI. You can experiment with that too, perhaps with the second code example above.

I would be interested if you felt that the above manual adjustments of the Table were simply too onerous -- if say you desperately needed a command that would just display exactly what you wanted, perhaps because you needed to do it many times. (The Table adjustments are clobbered if you re-execute the BodePlot call.)

 

acer

First 237 238 239 240 241 242 243 Last Page 239 of 336