Joe Riel

8216 Reputation

22 Badges

15 years, 124 days

MaplePrimes Activity

These are replies submitted by Joe Riel

I assume you mean a template something like the Custom Component template, which works for continuous models. It could be extended to handle discrete models.  Do you have an example of discrete equations you want to model?

@acer That's a much better example than mine. 

@Anthrazit The mint facility can help here.  While it doesn't flag such a call as an error (it isn't, syntactically), if called with infolevel 4 you can see all the function calls.  While mint is normally used with external text files, you can use my CodeBuilder package, available via the Cloud, to run mint on code edit regions.  Here's a snippet of the output when doing so with your worksheet:


# that pops up a maplet with the display.  I've selected the relevant lines

Procedure IndirectCall() on lines 9 to 11
  Global variables usage: 
      CatchMeNot was called as a function
  These functions were called:  CatchMeNot

Any global variable usage should be looked at with suspicion.  The output also includes

Procedure CatchMe_Not() on lines 5 to 7
  These names were used as global names but were not declared:  SetProperty
  Global variables usage: 
      SetProperty was used as a value

While that is legal, it isn't ideal.  To correct this either forward quote SetProperty, or, better, use the colon-dash operator:  DocumentTools:-SetProperty.  The value argument passed should either be forward-quoted, or double-quoted (a string, which is accepted by DocumentTools:-SetProperty). Because value is a protected name, using it unquoted is mostly innocuous, however, it's good practice to quote such names.

@Anthrazit Unevaluated functions are frequently used to return a result that could not be evaluated.  They are also used as data structures, sometimes in conjunction with the `print/foo` facility, where foo is the function name; an unevaluated function call to foo, when displayed, will use the result of `print/foo` if such a procedure is defined.  This functionality is old.

Note that read and save are similar, that is, they are part of the Maple language and don't need parentheses, though are frequently seen with them.

@Carl Love Am thinking it should be feasible to extend specfunc to handle this.  That is, the format could be specfunc(type*, type, f), where the second argument (type) matches the remaining arguments in f (after matching those specified by multiple types). Then the answer could be type(., 'specfunc(specfunc(posint,g), posint, f)'). 

@BenOve Alas, you need to unpack the help database that comes with it; without it will be hard to figure out. Did you try running the command after first calling trace on it, as I showed in a previous response?  It would be better to get to the root of the problem.

@Thomas Dean Did you try Syrup:-About()?  It should return a record.  Not a big deal if it doesn't, since it isn't used for anything.

Hmm.  It worked fine here.  Am wondering if maybe it cannot create the appropriate subdirectory where it is supposed to install the toolbox.  What happens when you run the following in Maple


I expect the same issue.  Alas, PackageTools:-Install doesn't have any userinfo statements to provided convenient observation.  You might do



@mmcdara The not is easy enough to understand.  To understand the rest, you might inspect the help page ?type,structure, where the second entry (there are quite a few) indicates that a list of types (here [nonnegint,nonnegint,nonnegint], which is what [nonnegint$3] evaluates to) is a type that matches a list of elements of the corresponding types.  Note that you can also do [n,x,y] :: Not([nonnegint$3]).

I probably would have eliminated the negation and swapped the terms in the conditional expression and also used and

elif n::nonnegint and x :: nonnegint and y :: nonnegint then
end if;

A variation that avoids the $ operator is [n,x,y] :: 'list(nonnegint)'

Could you give a small example of what you want?

@Carl Love PrintSystem won't work here, it's input is supposed to be a DynamicSystems system.  What he wants is probably

num := [a,b,c]:
den := [a,b,c,d]:
sys := TransferFunction(num, den):

For the OP: See the help page for DynamicSystems.  You can directly pass sys to various functions that might be useful.

@Eric Ragnarsson The problem there is that the matrix you inserted is in Maple syntax, which Modelica does not understand.  There are a couple ways to fix that. Here is one.  In the Maple session in which you assign the matrix (say M), execute the following

for indx, val in M do
   printf("M[%d,%d] = %a;\n", indx, val):
end do:

That should generate output like

M[1,1] = ... ;
M[1,2] = ....;

Cut and paste that block of output into the Modelica code editor, after the equation keyword.

@Eric Ragnarsson Use the green arrow to upload.  Offhand, your construction seems reasonable.

If memory serves, the matching failures occurs during the Pantelides routine when the structure of the model is being converted to a DAE (when algebraic loops are being broken). May indicate that the system is badly formed.  If you upload the model or email it to me I could either look at it or forward it to someone  who will. 

1 2 3 4 5 6 7 Last Page 1 of 184