Joe Riel

7727 Reputation

22 Badges

14 years, 143 days

MaplePrimes Activity

These are replies submitted by Joe Riel

Show an example of what you have done.

Could you upload the msim here?  Use the green arrow.

I cannot tell what you really want, but suspect that assign(Equate(C,A)); would achieve it. The effect of the assign is to create a procedure named c with a remember table.

@aaeerr First, I copied that code from the displayed code shown in the code region in the Equation Extraction app, then added the statement at the end.  The code goes into a worksheet that is linked to the MapleSim model. You could also run it standalone, in a separate Maple worksheet, by changing the first statement to something like

A := MapleSim:-LinkModel('filename' = "HW4.msim"):

then continuing with the other commands. Here's a brief explanation of what each line does

Connect to the the MapleSim model. A is assigned a Maple module with exports that allow interacting with the linked model.

A := MapleSim:-LinkModel('filename' = "MW4.msim"):

Select the subsystem of interest. This isn't necessary because you are interested in the entire model.


Define shorter names for the parameters and variables of interest. You can use A:-GetParameters('allparams') to list all the parameters, and A:-GetVariables() for the variables.

A:-SetSubstitutions([`Main.SpringDamper.c` = c__SpriD, `Main.SpringDamper.d` = d__SpriD, `Main.SpringDamper.phi_rel0` = PhiR0__SpriD, `Main.Revolute.M`(t) = M__Revolute(t), `Main.Revolute.theta`(t) = theta__Revolute(t)], 'nocheck'):

Get the equations. See the help page for LinkModel,GetEquations for the options.

eqs := A:-GetEquations('output' = 'all', 'inputs' = {}, 'filter' = [], 'simplify' = true, 'params' = {`Main.SpringDamper.c`, `Main.SpringDamper.d`}):

Get the differential-algebraic equations. Note that the lhs should really be named daes; the displayed code has a typo which prevents the next line (in the app, not here) from working.

dae := eqs[1];

Call isolate to isolate the variable M__Revolute(t) in the second equation in daes (this assumes the ordering is consistent, which may not be case) to the lhs, then call subs to eliminate it from the first equation.

subs(isolate(dae[2],M__Revolute(t)), dae[1]);

@Basak My mistake.  I had put your code in a procedure to permit easier debugging but didn't declare all variables as globals.  Doing so masks your problem. What is actually happening is that tj is assigned NULL. Put a print statement after the call to tj := solve(eqtj,tj) and you'll see the problem.  Maybe that should be solve(eqtj, p)?

@acer A chance for the rarely used mul:


@acer Nice extension.

@acer Both solutions offered use the determinant.  Suppose the set only consisted of three vectors (of dimension 4).

@Carl Love The bigger problem with that many positional parameters is that it is hard to visually check whether the call is correct. A way around that is to use keyword parameters, the call is then sort of self-documenting.  The same issue arises when using a vector or array to group values; for that reason I generally prefer using a record.  Debugging and maintaining is generally easier when you can associate a meaning with a value.

@assma Thanks for the explanation.  I don't have 2017.0 immediately available to check it on; it looks fine in 2018.2. What OS are you using?

Explain what you think is wrong.  The plot in the worksheet is correct for the given input.

@Kitonum I'm thinking maybe the posted worksheet is not what he has. Or possibly he doesn't realize that, after calling the assign procedure, the values of a and b are assigned so that the evaluation of v(x) does not have a literal a and b (they are globals, not arguments of v), but rather their numeric values. If the latter is the issue, then a and b can be unassigned, say with

a := a': b := 'b':

I don't understand what you think is wrong.

@acer Good point, I hadn't noticed that. It would be safe to use RK__1, which will look the same in 2D output.

Consider uploading your mw file here.  Use the green up arrow.

4 5 6 7 8 9 10 Last Page 6 of 178