Joe Riel

8059 Reputation

22 Badges

15 years, 21 days

MaplePrimes Activity


These are answers submitted by Joe Riel

With recent versions of Maple Standard, the current directory is displayed in the status bar (bottom of window).  Click on the display to bring up a directory browser to change the current directory.

See the help page for try/catch.  It mentions that a stack overflow is not trappable, which is reasonable.

The problem in `discont/zero` is that it factors a particular expression f into -I*(I*f) then recursively applies itself to both factors, which won't terminate. 

Having a static module inside an object means that module will be shared by all objects of the class.  As such, it doesn't make sense to have non-static things inside the module. Specifically, big_car_name will be the same as the last assigned 'name' for all the objects.  If that is what you want, it seems better to just declare big_car_name as a static local to car_class.  However, you could still do what you want, but I'm not seeing a reason to be passing an object into big_car:-set_name.  So to keep the submodule, I'd do something like

car_class := module()
option object;

local name :: string :="UNKNOWN";

export
    set_name::static:=proc(o::car_class,nm::string)
        o:-name := nm;
        big_car:-set_name(nm);
    end proc;

    #this is module, that I want to be private to this class only
    #eventually, I'd like this module be in separate mpl file also.
local
    big_car :: static := module()  #module does not take arguments!

        #this below should be private only to the this module
        #and not seen by the enclosing object.
    local big_car_name :: static(string) := "UNKNOWN";

        #this export to allow parent object to call it
    export set_name :: static := proc(nm :: string)
        big_car_name := nm;
    end proc;

    end module;

end module:

o:=Object(car_class);
o:-set_name(o,"GM");

Note that I also renamed '_name' to 'nm'. While not an issue here, symbols with leading underscores are supposed to be reserved for Maple library stuff; it's better not to be use them.

There are a couple ways to do this.  One is to open attach a Maple worksheet to the MapleSim model, get the data for the simulation by using the LinkModel and Simulate, import the data for the comparison (using the Maple Import command, or something equivalent), then plot both in Maple.  Something like the following

A := MapleSim:-LinkModel():
simdata := A:-Simulate('returntype=datapoint'):
extdata := Import("MyData.xls"):
# plot the x (say 2nd col) vs t (1st col) of simulation and external data
plot([simdata[..,[1,2]], extdata[..,[1,2]]]);

An alternative approach is to do this entirely in MapleSim. Attach the external data to the MapleSim model, then insert a time table (Signal Blocks > Interpolation Tables > Time Table) and set it to use the attached data (assuming data is in proper format). The output of the block should then reproduce the data of interest. Probe it and compare to the simulated probe.

With this second approach it is fairly easy to generate an error signal between the two (form the difference, square and integrate) and then use the ParameterSweep and Optimization apps to fit model parameters.

If the read command, which reads maple source code, results in assignments to EQ_1, EQ_2, etc., then you can simply do

EQlist := [EQ_1, EQ_2, ... ];

Is that Maple15 (quite old) or Maple 2015?  Regardless, neither can read a .maple file.  The format is an sqlite database, so you should be able to use sqlite to extract the contents of the file.

It's a standard ascii source file. Such files are not typically "opened" in Maple. Rather they are edited with a text editor and either read into Maple,

   read "somefile.mm";

or loaded into a Maple archive (.mla file) which is then accessed in various ways.

A long time ago I wrote a package for doing that and related stuff, such as generating a type cover for a set of expressions.  For the most part it isn't particularly useful. I haven't kept it current (with newer types).  Here's what it does with 4 (your example):

WhatType:-WhatTypes(4);
  {MVIndex, algfun, algnum, atomic, complex, even, finite, integer, literal, numeric, polynom, posint, radfun, radnum, ratpoly, scalar, type, algebraic, anything, appliable, complexcons, constant, embedded_axis, embedded_real, expanded, filedesc, monomial, nonnegative, nonnegint, operator, positive, property, radalgfun, radalgnum, rational, realcons, verification, extended_numeric, extended_rational}

WhatType:-WhatTypes(4+x);
   {`+`, algfun, linear, polynom, radfun, ratpoly, scalar, algebraic, anything, appliable, expanded, radalgfun}

WhatType:-WhatTypes([4+x]);
    {list, anything, appliable, indexable, sequential}

Guessing at what you want, here's one approach, a bit crude.

T := table([2=3,3=2,5=6,6=5,7=9,9=7]): # define given transformations of second index
map(proc(x) local y := T[op(2,x)]; if y :: integer then B[op(1,x),y] else x end if; end proc, varA);
[A[1, 0], A[1, 1], B[1, 3], B[1, 2], A[1, 4], B[1, 6], B[1, 5], B[1, 9], A[1, 8], B[1, 7], A[2, 0], A[2, 1], B[2, 3], B[2, 2], A[2, 4], B[2, 6], B[2, 5], B[2, 9], A[2, 8], B[2, 7], A[3, 0], A[3, 1], B[3, 3], B[3, 2], A[3, 4], B[3, 6], B[3, 5], B[3, 9], A[3, 8], B[3, 7]]

I cannot say I've ever depended on using the interrupt button. A better choice might be to use an embedded component toggle button then have the loop query it each time.  Something like

   do
      finish := evalb(DocumentTools:-GetProperty("ToggleButton0","value") = "true");
      if finish then
         # assign something
         break;
      else
         # assign something else
      end if;
   end do:

The usual way is

initeqs := [seq(S[i] - a[i-1] = 0, i=1..n)];

however, that assumes the constant ai is indexed rather than an inert symbol constructed via a__i. The latter can be generated with cat

initeqs := [seq(S[i] - cat(a__,i) = 0 i=1..n)];

Your notation is incorrect.  What you want is diff(T,d).

Just remove the list from fibs.  Using a list (or set) causes subs to do a simultaneous substition.  In this case you don't want that because e expands to an expression in terms of c and d, so you need to first substitute for e, then for d, then for c.  So use
 

fibs := ( e = c + d,  d = b + c, c = a + b ):  # changed brackets to parentheses

There is a package, UTF8, on MapleCloud (coincidentally written by myself), that will compute the length of the string treating multi-byte characters as single characters.

s := "décember"):
S := UTF8(s):
length(S);
                     8
Substring(S,1..2);
                   "dé"

The problem is the loop.  Because you are terminating it with a semicolon, the assignment to Y is being sent to the print stream; you can see this by commenting out the writeto statements. Because this is being run in the GUI the output is converted to typesetting stuff. To turn that off, just terminate the loop with a colon, that will suppress the undesired output.

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