MaplePrimes Questions

RandomCompositions:= module()
local
Compositions, Rand,
ModuleApply:= proc(n::posint, k::posint)
local C;
Compositions:= [seq(C-~1, C= combinat:-composition(n+k, k))];
Rand:= rand(1..nops(Compositions));
()-> Compositions[Rand()]
end proc
;
end module:
R:= RandomCompositions(8,6):
n:= 3:
S:= 'R()' $ n;
map(lhs=rhs/n, Statistics:-Tally(op~([S])));

[0 = 7/3, 1 = 5/3, 2 = 4/3, 5 = 1/3, 6 = 1/3]

plot([S],x=0..8,style=point);

I have  plot problem .

I want to plot the statistics result,but it runs error.

 

 

Here is one example:

restart;
alias(DS=DynamicSystems):
zeros :=[-1,-2]:
poles :=[0,-4,-6]:
gain  :=5:
sys   :=DS:-TransferFunction(zeros,poles,gain):

now sys above is a transfer function "object". But how would one go about extracting its properties? For example, I'd like to read the actual rational polynomial in s that represents the transfer function, which is embedded inside this oject, but I am not able to find an API to read it. I can only print it to the screen :


DS:-PrintSystem(sys);

But I'd like to assign the  "tf" printed above (the rational polynomial) into a seaprate variable, so I can extract the numerator and denominator if I want to. I have looked and not able to see a way to read this out. I just started learning this package.

Any idea how to look into these system objects? This does nothing:

o:=DS:-PrintSystem(sys);
whattype(o);
o[1];

Using Maple 18. I am looking for a programmable approach, using code. Not a click and point and menu based solution.

 

Hello,

In my model, it seems that I have parameters which are not evaluated.

Indeed, I'm not sure that the parameters defined with relations as you can see in the printscreen are evaluated.

 

One point which helps me to debug my model is to follow the evaluation of the construction of my model with the 3D visualization.

Questions :
1) How can I do to be sure that my parameters are evaluated ?

2) Is it possible to launch the update of the 3D visualization even if I still have some bugs in my model ?

Thank you for help.

Hi All,

I'm a new Maple user and I just have a question about evaluating a formula.

Say that you have a formula y=45*r*t

and you know what "r" is, lets say r=5

What do I do if I want to evaluate this formula for the values t=2 all they way up to t=150.

Is there a simple command that lets me do this?

 

Yours

John.

 



Hello, 

During the simulation of my model, I received this bug:

"cannot resolve function `Main.'Typesetting:-mambiguous'`; there is no function `'Typesetting:-mambiguous'` visible in model `Main`"

Have you a idea of the problem ?

How can I localize my issue ? Is there some options to localize the issue with a debug mode ?

Thanks a lot for your help

 

According to help here  on display, it says "The options parameter can include plot options as described in the plot/option "  and when  I go to the plots/option I see legend there. But when I try to use it, I get an error that plots:-display does not accept the legened option.

I am generating 2 plots, and use display() to show them on one axes. But need to add a legend as well. Is there a correct way to do this? 

restart:
with(DynamicSystems):
with(plots):
sys := TransferFunction(1/(s^2+0.2*s+1)): 
p1:=ResponsePlot(sys, Step(),duration=50,color=red):
p2:=ImpulseResponsePlot(sys,50);
display([p1,p2],axes=boxed, title=`step and impulse reponses`,legend=["step","impulse"]);

Now if I add legend, it fail

display([p1,p2],axes=boxed, title=`step and impulse reponses`,legend=["step","impulse"]);

I am sure I am doing something wrong. How to add legend to display? I can't use plot([...]) since the plots are allready generated by other Maple functions.

 

 

I am generating polynomials and I want to iterate each term in the polynomial and do something accordingly. I collect the first term. I wish to extract the tuples of 1,1,1 and 2,1,1 out and do some calculations.... Do you know how I could achieve that? Thank you:)

 

expr1 := mu*(h[1, 1, 1]+h[1, 1, 2]+h[1, 1, 3]+h[1, 1, 4])+J1*(h[1, 1, 1]*h[2, 1, 1]+h[1, 1, 2]*h[2, 1, 2]+h[1, 1, 3]*h[2, 1, 3]+h[1, 1, 4]*h[2, 1, 4])+2*J2*(h[1, 1, 1]*h[1, 1, 3]+h[1, 1, 2]*h[1, 1, 4]+h[1, 1, 3]*h[2, 1, 1]+h[1, 1, 4]*h[2, 1, 4]);
mu (h[1, 1, 1] + h[1, 1, 2] + h[1, 1, 3] + h[1, 1, 4]) + J1 (h[1,

1, 1] h[2, 1, 1] + h[1, 1, 2] h[2, 1, 2]

+ h[1, 1, 3] h[2, 1, 3] + h[1, 1, 4] h[2, 1, 4]) + 2 J2 (h[1,

1, 1] h[1, 1, 3] + h[1, 1, 2] h[1, 1, 4]

+ h[1, 1, 3] h[2, 1, 1] + h[1, 1, 4] h[2, 1, 4])
expand(expr1);
J1 h[1, 1, 1] h[2, 1, 1] + J1 h[1, 1, 2] h[2, 1, 2]

+ J1 h[1, 1, 3] h[2, 1, 3] + J1 h[1, 1, 4] h[2, 1, 4]

+ 2 J2 h[1, 1, 1] h[1, 1, 3] + 2 J2 h[1, 1, 2] h[1, 1, 4]

+ 2 J2 h[1, 1, 3] h[2, 1, 1] + 2 J2 h[1, 1, 4] h[2, 1, 4]

+ mu h[1, 1, 1] + mu h[1, 1, 2] + mu h[1, 1, 3]

+ mu h[1, 1, 4]

I'm taking my first steps with maple and pdsolve, trying to run the example in the maplesoft support page:

http://www.maplesoft.com/support/help/Maple/view.aspx?path=examples/pdsolve_boundaryconditions

which reads

>
> restart; with(PDEtools);
> U := diff_table(u(x, t));
>

and I get a solution that is different from the web page, and when i run

Im using maple 13. Any tips about what's wrong?

 

regards

One can write 

restart;
alias(C=binomial);
C(4,2);

or

restart;
C:=binomial;
C(4,2);

and then both work the same. In the first case, the replacement of "C" by "binomial" is done at parsing time before evluator gets hold of the code, while in the second case, the replacement is done at run-time (evaluation).

So alias will be more efficient and more safe, I assume.

Is that all there is to it, or are there other more subtle and important reasons to use alias vs. :=  when one want to bind long name to smaller ones to save on typing.

 

I am newbie in Maple, and trying to understand when to use operator `if` as I see in some code vs. normal if. This is in context if using map()

I noticed I can write

A:=[seq(i,i=1..10)];
f:=x->x^2;
map(x->`if`(x<5,f(x),NULL),A);

or

map(x->if x<5 then f(x) fi,A);

And they both work the same. When should one use `if` vs. if? with the case of `if` I had to give a third argument NULL for the else part, while with using direct "if", I did not have to give the "else" part.

Also, suppose I want to use  IF .. THEN .. ELIF ... FI, then how would this be done using the operator syntax? in normal "if", I can write

A:=[seq(i,i=1..10)];
f:=x->x^2;
map(x->if x<5 then f(x) elif x=5 then x else x-1 fi,A);

Actually if I understand better when `if` is meant to be used vs. where the normal "if", I might understand more its use. 

 

ps. I did look at the help here but did not see it recommend when to use over the other (unless I overlooked it)

 

 

 

 

Test_modify.mwGood Morning Everybody,

Can anybody demonstrate how I can convert the output from the procedure into an N X N Matrix depending on the nops from the attached file. Thanks everybody.

 

Regards,

 

Moses

 

Hello,

In a subsystem, i defined parameters like this in the "parameters" area :

 

In the "diagram" area, the parameters are not updated because i see this panel :

 

Do you know why the parameters are not updated (possibly only on visualization) ? And if yes, how i can do to visualize in this last panel the value of the parameters updated ?

Thanks a lot for your help

Hi,

 

I want to calculate a new position (X,Y,Z) for a cartesian model with 3 points (dX,dY,dZ) but  I got a problem, my point is a parameters, so I can't change it in the simulation in real time with a Input signal on the components. Does It exist a solution for convert a parameters to a variable to get a Input signal?

Exemple of my calcul:

eq:= [x(t)= dx+sin(dy/dz), y(t)=dy+20,z(t)=dz]

 

Thanks!

with(LinearAlgebra):
a:=Vector([1,2]);
b:=Matrix([[1,2],[1,2]]);

Say if I need a^T * b * a, I will do this:

VectorMatrixMultiply(Transpose(a), b);
VectorMatrixMultiply(%, a);

But this seems too long for such a simple matrix (and vector) computation. I am sure there must be an short way.

What if I need more computation, like

 

a^T * b * c*d*f*g* a, where c,d,f,g are other 2x2 matrices.
 If I were to use the above command, that'll take a long time to input.

Thanks,

First 1387 1388 1389 1390 1391 1392 1393 Last Page 1389 of 2427