## 345 Reputation

10 years, 64 days

## Problem of global variable between modul...

Maple

Hello,

In a module, i have defined a global variable GeometricData. I would like to use this variable in procedures which are inside the module. How can i define variables in a module which can be used in procedure inside a module ?

In my code below, the variable GeometricData is not seen by the procedures.

```MonPackageFonctions:=module()
option package;
export GammaNum,psiNum;
global GeometricData;

GeometricData:=r=0.2,l=1;

GammaNum:=proc(xx)
global GeometricData;
Gamma := Pi-arccos((1/2)*(-x(t)^2+l^2-r^2)/(x(t)*r));
evalf(eval(Gamma,[GeometricData,x(t)=xx]));
end proc;

psiNum:=proc(xx)
global GeometricData;
psi :=-arcsin((1/2)*sqrt(-(x(t)^4-2*x(t)^2*l^2-2*x(t)^2*r^2+l^4-2*l^2*r^2+r^4)/(x(t)^2*r^2))*x(t)/l);
evalf(eval(psi,[GeometricData,x(t)=xx]));
end proc;

end module;
```

Thanks a lot for your help

Hello,

I know that it is possible to conduct the dynamics of multibody systems with MapleSim. But, is it possible to conduct only the kinematics ? Would it be possible to share a example where only the kinematics is conducted with MapleSim?

## Display a list of equations in column...

Maple

Hello,

I have a list of equations. I would like to display this list in column.
Problem : as each term of my list is an equation, i can not transform my list in a vector.
How can I do to display a list of equations in column ?

## Toward a portable module for using in Ex...

Maple

Hello,

In my worksheet (dedicated to the calculations of mechanism geometry), i'm trying to have a more "POO" approach (Programming Oriented Object).

In this sense, I begin to get more familiar with module and package. Attached, you can find a worksheet which gives the idea of the structure of my code. With this code, the module is very useful for me to call some results (attributes in terms of POO).

My way of doing is :
1) at the beginning, i use Maple as a calculator that is to say that at each prompt, i calculate expressions.
2) i try to make modules so as to have a easier access to the data that I calculated.

However, as the definition of the expressions that I calculated are outside my module (for example, in the worksheet attached, i calculate the expression of Gamma and psi before in my worksheet and i retrieve these expressions in the module with "global"), i can not use this module independently of this worksheet and namely in a Excel Addin.

In fact, the module works if the worksheet has been launched one time and consequently the expression of psi and Gamma are in the kernel (or in memory i want to say).

Question:

How can I do to transform my module in a independent and thus portable module ?

One idea will be to copy/ paste all the geometric calculations which have been done line by line inside the module.
However, i have many lines in separated prompts and moreover, it is always convenient to keep the line by line approach in the worksheet to make some tests.

I look forward to hearing your tips.

Thanks a lot for your help

MonPackage_ProcModule_variante4.mw

## Difference between a Module/ functions s...

Maple

Hello,

So as to build a function which gives several outputs, i have made a code with this manner :

Input:=[i1, ..., in]

Output:=proc(Input);

export o1, o2, o3
o1=f1(Input);
o2=f2(Input);
o3=f3(Input);
end module

End proc;

By doing, output1:=Output(Input):-o1; , i obtained my result. However, as my structure begins with the procedure (proc End proc), I can't export my result in package.

For this reason, I'm thinking about changing the structure of my code by starting with the creation of the module and put all the functions inside.

Input:=[i1, ..., in]

Output:=module():

export o1,o2,o3;
option package;
o1:=proc(Input)
f1(Input);
end proc;

o2:=proc(Input)
f2(Input);
end proc;

o3:=proc(Input)
f3(Input);
end proc;

End module;

Can you give me your feedback on the two structures ? Do you think that the second choice Module->Functions is more appropriated ?

Thanks a lot of your help and feedback.

 1 2 3 4 5 6 7 Last Page 2 of 31
﻿