Joe Riel

9660 Reputation

23 Badges

20 years, 3 days

MaplePrimes Activity


These are answers submitted by Joe Riel

One way to do this using the standard components is to use a reset integrator with its input driven by a pulse train and its reset input triggered when the pulse train goes low.  Here is an example, sawtooth.msim

One possibility is to insert a translational brake between the position driver and the connection to the prismatic joint. The housing of the brake is connected to the prismatic 1D input, while one of the flanged is connected to the position driver.  With the brake open, the positional driver has no effect, with it closed, it controls the position.

You might be better off passing the 'output=listprocedure' option to ?dsolve.  For example

deq := {diff(x(t),t,t)=1, x(0)=0,D(x)(0)=1}: 
integ := dsolve(deq,numeric,output=listprocedure):
xsol := eval(x(t), integ):
map(xsol, <0,1,2,3>);

The problem is that tables and procedures evaluate to names, and a name is of type polynom.  You could do

type(eval(T),polynom);
                                     false

however, the call to eval can be expensive. A better way is

type(T, 'And(polynom,Not(last_name_eval))');
                                     false

Note that your example using polynom(prime) is consistent; the prime refers to the coefficient, and the coefficient of T is 1, which is not prime.

You can do

FooBar := proc( fs::seq(And(polynom,Not(last_name_eval))), T::{procedure,table} )
add(x,x=A);

Musing:

Just as seq(i, i=1..4) can be shortened to seq(1..4), it might be neat, but probably not worthwhile, if the addition could be shortened to add(A).

The data structure you are asking for, a list of matrices, some of them repeated, is strange, though there may be a good, if unexplained, reason for it. The strangeness is that if you change an element in one of the repeated matrices, the corresponding element changes in its twins. Presumably that is the intent.

A comment on the suggested techique (from the link).  ?CurveFitting[PolynomialInterpolation] fits a polynomial of order n-1 to n points.  That is why the instructor's example only includes four of the 10 data points.  A better way is to use ?CurveFitting[LeastSquares], which allows you to specify the expression to fit to. Thus

LeastSquares(xpts, ypts, x, add(a[k]*x^k, k=0..3));

will fit a cubic polynomial, using all the data

The warning "nags" from the flattener, "no value specified for parameter ... " obscure a real error.  To see the actual error, click the "Display the message console" icon on the bottom toolbar, it looks like a small console (with horizontal lines representing lines of text).  You will then see

Simulation problem: maximum number of event iterations reached (100) at t=.11939218e-2

I haven't looked into this closely, but have dealt with similar configurations. The probable cause is the switching of the diodes.  As a simple but effective workaround, attach a large resistor, say 1Mohm, from ground to the left side of the inductor. 

I don't enjoy booting into Windows, so will show one approach that works in Linux.

Here is the file I created, named UpdateFile and made executable

#!/bin/bash

maple -q local cnt,file;
    file := "/home/joe/tmp.dat";
    cnt := readdata(file,integer);
    writedata(file,[cnt[1]+1],integer);
end proc();
EOF

From the command line

$ echo 0 > tmp.dat
$ ./UpdateFile && cat tmp.dat
1
$ ./UpdateFile && cat tmp.dat
2

@Christopher2222 Somewhat surprisingly, this problem is more difficult than it first appears. I've tried a few configurations with multibody components, however, they have not been completely successful. Investigating.

The ?product command is for computing indefinite products (symbolic products), while the ?mul command is for computing a definite product, that is one in which the terms and end points are defined. A practical difference is that mul does not first evaluate the multiplicand.

To see what is happening, use the inert form of product,

Product( (2*i-1) mod 3 + 1, i=1..10 );
                              10
                           --------'
                          '  |  |
                             |  |    (2 i + 3)
                             |  |
                             |  |
                            i = 1

Maple has evaluated the expression (2*i-1) mod 3 + 1 before passing it to Product.  That gives 2*i+3.  In product, that is then used to compute the result.

Does it make sense to connect a translational spring to a revolute joint? A rotational spring I understand; it applies a torque to the joint as it pivots. What do you expect the translational sprint to do? To connect a rotational spring, connect it to the unfilled circular port. However, the revolute joint takes spring and damping parameters, so that generally isn't required.

Maybe you want a translational spring between two arbitrary points.  Assuming the movement is in a plane, you can attach separate revolute joints to each, then connect the revolute joints with a prismatic joint.  The prismatic joint has spring coefficient and damper parameters, so you can use those, or you could attach a 1D translational spring between the two rectangular ports on the prismatic joint.

 

In each procedure that accesses a member of LinearAlgebra, you can do

myproc := proc()
local x,y,z;
uses LinearAlgebra;
...
end proc:

That isn't the best style in that it exposes all exports of LinearAlgebra to your procedure, which could be an issue if you happen to use a local procedure/variable with the same name as an export of LinearAlgebra.  The way I avoid that is the following

myproc := proc()
...
uses LA = LinearAlgebra;
   ...
   M := LA:-MatrixMultiply(...);
end proc:

Using this form of ?uses allows a reasonably convenient shortcut to access LinearAlgebra exports, but doesn't export the exports, so accidental conflicts do not occur.

An easy way to debug this is to use the Maple debugger:

stoperror(all):
(**) decom(3,2);
Error, invalid subscript selector
decom:
  13         s[i,k] := [op(s[i,k]), op(f[i,k,l])]
DBG> s;
[]  

The expression s[i,k] is invalid with i and k integers (here 1, 1), and s assigned an empty list.

 

If you are satisfied with the output in text format, rather than typeset, you can do

printf("%{}a\n",<f1,f2,f3>):
First 38 39 40 41 42 43 44 Last Page 40 of 114