Joe Riel

9555 Reputation

23 Badges

18 years, 304 days

MaplePrimes Activity

These are answers submitted by Joe Riel

Using mint, Maple's syntax checker, is helpful. Because it works with external source files, an alternative is to use maplemint. For example

(**) foo:=proc(expr)
(**)   local x;
(**)   map(x->x^2,expr);
(**) end proc:
(**) maplemint(foo);
Procedure foo( expr ) 
  These local variables were never used:  x


Is Ti the sampling period?  Regardless, for now the easiest way to handle this is to either construct the model graphically, using discrete components, or to write Modelica code for the model.  I've taken the latter approach. See DigitalControl.msim. Double click on the dig model to open a Modelica editor that displays its code.

What type of joint?  A multibody rotational joint?  It has a builtin damping constant.  For other types of friction you can connect a 1D rotational device between the two 1D rotational ports on the multibody rotational joint.

The installation command is wrong (it is different in the zip file than what you show). The correct command is

PackageTools:-Install("this://", overwrite)

The incorrect one used backslashes, not forwardslashes.

There is no direct method, but there are ways to debug this.  A good practice is to minimize the amount of explicit code in an embedded component.  I usually limit this to a single procedure call.  When that procedure call is not working, I then use the maple debugger to find out why.  I have a personal set of tools for doing so, but here is a simplified version that might help.  Create the Maple procedure

dbg := proc(p) stopat(p); p; end proc:

It sets a breakpoint in the procedure passed to it, then returns the procedure.  Modify the code used for the non-working button to


Now, when you click the button you get an error, Error (in stopat) procedure name expected.  That indicates that CatchMeNot is not actually assigned a procedure, which is the case.  If it were assigned a procedure, then it would have launched the debugger and you could step through its code to find say, an operational error.

The DynamicSystems package has GainMargin and PhaseMargin commands to do precisely that.

If you want globals, a simple method is


Note that you can use multiple ranges, or a mix of ranges and other stuff in cat

 cat(x, 1..3, `_`, 2..4);
                                  x1_2, x1_3, x1_4, x2_2, x2_3, x2_4, x3_2, x3_3, x3_4

Ranges do not have to be numeric

cat(x, "a" .. "b", `_`, 2..4);
                                           xa_2, xa_3, xa_4, xb_2, xb_3, xb_4


Have you looked at the ImageTools package?

One solution is

type(f(g(1),3,3,4),'And(specfunc(f), patfunc(specfunc(posint,g),posint))');


The annotation associated with each port defines its position.  Change the extents to

extent = {{-120, 40},{-100,60}}  // for first input
extent = {{-120, -60},{-100,-40}} // second input

Each extent has the form {{x1,y1},{x2,y2}}, the points define the diagonal of a rectangle.


For a slightly nicer looking block (white background rather than see-through), add the following line, say after the model line

extends Modelica.Blocks.Icons.Block;


Another possiblity is to use ArrayTools:-Alias to allow access to a Matrix (or any rtable) created with a different offset.  For example

M := Matrix(3):  # 3x3 matrix
A := ArrayTools:-Alias(M, [0..2,0..2]):  # alias
A[0,0] := 23:


Here's how it can be solved using Syrup, which is available on the Maple Cloud:

ckt := [V(a+b*t+c*t^2),R,C]:
(deqs,rest) := Solve(ckt,'tran','returnall'):
dsol := dsolve(deqs):
subs(rest, dsol, v[C](t));



Assuming this is a discrete system, here is one approach.

K := [0.1, 0.2, 0.3, 0.4]:
# Assign the z-transform from the impulse response.
T := add(K[k]/z^(k-1), k=1..4);
sys := StateSpace(T,'discrete');
# Display the a, b, c, and d matrices
use sys in a,b,c,d; end use;
# Plot the impulse response


Currently there is no way to create matrix i/o using the CustomComponent template.  It wouldn't be hard to extend it to allow this.  In the meantime, you can do so by writing Modelica.  As an example, here is a block with a matrix output:

model foo
    import MBI = Modelica.Blocks.Interfaces;
    output MBI.RealOutput y[2,2] annotation (Placement(transformation(extent={{100,-10},{120,10}}))); 
    y[1,1] = time;
    y[1,2] = 0;
    y[2,1] = 0;
    y[2,2] = sin(time);
end foo;

Currently the MapleSim GUI doesn't expect matrix signals; as such you won't be able to probe the output.  But you can connect it to another block that expects a Matrix input and it will work.  I've attached a simple model that does this; it uses the foo model shown above and connects it to a bar model.  MatrixIO.msim

Am not sure this is the best way to go.  It might make more sense to write a function (in the Modelica Code Editor) that returns a Matrix and then use that in a block. 

This is available via the Iterator:-Permute function.

P := Iterator:-Permute([2,1,1,3]):
for p in P do printf("%d\n", p); end do:
1 1 2 3
1 1 3 2
1 2 1 3
1 2 3 1
1 3 1 2
1 3 2 1
2 1 1 3
2 1 3 1
2 3 1 1
3 1 1 2
3 1 2 1


First 8 9 10 11 12 13 14 Last Page 10 of 114