nm

11483 Reputation

20 Badges

13 years, 84 days

MaplePrimes Activity


These are questions asked by nm

In Maple, I seem to keep finding commands in different Maple build-in packages that does the same thing. Which is very confusing for someone trying to learn Maple.

Maple seems to have good things in it, but at the same time, it strikes me as a large bag with lots of tools and commands thrown in with little sense of coherence. One needs one command from one package to finish the job started using a command from a different package, and an option from one place to patch something done with a command from another package.

Here is one example. I wanted to obtain the diagonal of a matrix. So far, I found 3 commands that do the same exact thing:

A:=Matrix([ [1,2,3],[4,5,6],[7,8,9]]);
MTM:-diag(A);  #1
LinearAlgebra:-Diagonal(A);  #2
Student:-LinearAlgebra:-Diagonal(A);  #3

I am sure if continue to look, I might find another command to do the same thing hiding in some other package.

The problem for new user like me, is how does one decide which comand to use. This is the same as with constructing a Matrix. There is the Matrix([[]]) notation and metod, and there is the <<>> notation that does the same thing but with different and conflicting syntax.

Having many commands that do duplicate things is not a good thing at all. Commands should be axiomatic and orthogonal to each others. I think there should be a document that describes from a high level all these packages, may be as a block diagram with arrows that show the relation, if any, between them, and how they interact and when to use one vs. the other.

Is there a reason for this duplication of functionality? Does any one at Maplesoft look at such issues?

 

I figured how to insert row in middle of a matrix using <<>> notation. But I am trying to stick to one notation which is the Matrix() and Vector() for now. 

Here is what I am trying to do. Insert a row in the third row of  Matrix. This works:

A:=< <1|2|3>,<4|5|6>,<7|8|9>>;
A:=<<A[1..2,..],<90|91|92>,A[3,..]>>;

But when I try

A:=Matrix([ [1,2,3],[4,5,6],[7,8,9]]);
A:=Matrix([ A[1..2,..], [91,92,92], A[3,..] ]);

Error, (in Matrix) this entry is too tall or too short: [91, 92, 92]

I also tried:
A:=Matrix([ A[1..2,..], Vector[row](91,92,92), A[3,..] ]);
A:=Matrix([ A[1..2,..],Matrix([[91,92,92]]), A[3,..] ]);

I am starting to think I should go back to using <<|,|,|>> notation, even thought I do not like it, but at least it seems more logical. 
How would you insert row in middle of matrix, using Matrix() constructor from an existing Matrix?

 

 

I am learning a bit of Maple. I noticed I can use map and seq to obtain the same result I want. So I was wondering when to use each, or if it just a style issue or if there is more to it.

I am sure there are cases when map can only be used, and cases when seq() only can be used. But are there general rules of thumb to look for when deciding which to use? Here is an example of what I mean

restart;
plot( map(i->i*sin(t),[seq(i,i=.1..1,.2)]),t=-2*Pi..2*Pi);   #1
plot( [seq(i*sin(t),i=.1..1,.2)],t=-2*Pi..2*Pi);  #2

Both give the same result

I kind'a like map more myself, but seq is a little shorter in this case. Just looking for thoughts and hints from the experts.

 

One would expect that hitting F3 will split from _end_ of the current line (where the cursor is at).

But what Maple does is actually split everything from the current cursor location. Which means if the cursor happened not to be exactly at the end of the line, the current line itself will also be split and broken.

It is much more logical to split starting from end of current _line_ (where the cursor is at), not current character, because that is what normally one would want to do. One will have large block of code, and want to split it from one line down to the end.  It is a simple usability issue, which Maple UI seems to suffer allot from.

Is there a way to modify this behavior? I keep hitting F3 and forget to move the cursor to the end of the line before, and end up wasting time having to fix things afterwords since the line itself is split.

 

 

This is a typical problem of what I find when learning DynamicSystems. Basically, I create number of systems by changing one paramter (the damping ratio in this case) and want to plot the unit step of all of them on the same plot to compare the effect of the damping ratio.

I setup the TransferFunction, used Simulate to obtain the response of each to the same input. The problem comes when I want to plot the respones.  I have to use plot[odeplot] it seems. But this only like to take one response at a time.

I can't use plot() since I do not have the actual function of the response in time. Unless I try to extract the differential equation from the sytem object, solve that and get a solution then use plot(). But if I do all of this, what do I need DynamicSystems in first place? 

I will show what I tried. I am sure there is some way to do this in Maple I just do not know yet the correct function or setup.

restart;
alias(DS=DynamicSystems);
H:=(w,zeta)->w^2/(s^2+2*zeta*w*s+w^2);
sys:= (w,zeta)->DS:-TransferFunction(H(w,zeta)):
sol:=seq(DS:-Simulate(sys(1,zeta),Heaviside(t)),zeta=0.1..1.2,.2):

Now I want to plot all the solutions in sol. I wanted to use plot(...) only to be able to obtain the automatic coloring of each solution.

If I try to use plots[odeplot], it works, but only on one at a time:

plots[odeplot](sol[1],t=0..10);

If I try this, it fails:

plots[odeplot]([sol],t=0..10);

I can get each plot separatly and then use display() but then lose the automatic coloring of the lines:

plots:-display(seq(plots[odeplot](sol[i],t=0..10),i=1..nops([sol])));

I am looking for the above plot, but have the lines each colors differently. I also need to figure how to add legend later. But one step at a time. I can't hard code the color in the plots[odeplot] call itself, since I do not know what color to give each line. plot([....],t=0..) allready does this automatically. But I can't use it!

Just to give an idea of the kind of plot I am trying to obtain, here it is in Mathematica:

sys = TransferFunctionModel[w^2/(s^2 + 2 z*w*s + w^2), s];
zValues = Range[.2, 1.2, .2];
fun = OutputResponse[sys /. {w -> 1, z -> #}, UnitStep[t], {t, 0, 12}] & /@ zValues;
Plot[Evaluate@Flatten@Table[fun[[i]], {i, 1, Length[fun]}], {t, 0, 12}, Frame -> True, PlotRange -> {{0, 12}, {-.1, 1.7}}]

 

 

 

First 189 190 191 192 193 194 195 Last Page 191 of 202