quo

25 Reputation

4 Badges

8 years, 40 days

MaplePrimes Activity


These are questions asked by quo

how can I print my equation or configure maple so that they don't try to autofit themselves in the window? and what would the best way to export them to MATLAB be? I know there's the codegeneration command.

 

For example, I noticed that the output of some commands like StateSpace prints the equations in a way that if they are too long, they won't try tu fit, but rather it lets you scroll to the right:

 

I have a set of 15 equations in state space form, and I'm just trying to program a way to substitute all variables representing the time derivates as for example x__s_dot (t) as diff(x__s (t), t)  and diff( x__s_dot (t),t) as diff(x__s (t), t,t) so I can manipulate my equations easier.

The last half of the list xx has the variables that I want to substitute, the x,y and u (with respective diff(x__s (t), t) ) variables are always constant, but in the case of zeta, eta and u I might have indexes from 1 to n , in this case just 1 and 2.

I tried a bunch of methods including creating vectors with the seq, op commands and substituting them into my original equations with subs, algsubs but none of the things I programmed worked the way I wanted, I ended up with a very inefficient way , doing it manually, but the point is that I wanted to automate this bit. I've been doing maple for about 2 weeks and I still struggle a lot with it, I would greatly appreciate any guidence/advice.


My original equations are actually much bigger and my original code too, I tried to shorten it a bit just for making my problem simpler to understand but the equations still look really big here, If there is another way to format this question please do advice so.

EDIT : I think my last code was hard to understand because my equations were too big and it looked all messy and horrible, I edited to show just one vector of variables, I think that if it works here, it should work on the rest of my code:


 

NULL

interface(rtablesize=50):

xx := [x__s(t), y__s(t), u__s(t), x__r(t), y__r(t), u__r(t), x__c(t), y__c(t), u__c(t), zeta__1(t), eta__1(t), u__1(t), zeta__2(t), eta__2(t), u__2(t), x__s_dot(t), y__s_dot(t), u__s_dot(t), x__r_dot(t), y__r_dot(t), u__r_dot(t), x__c_dot(t), y__c_dot(t), u__c_dot(t), zeta__1_dot(t), eta__1_dot(t), u__1_dot(t), zeta__2_dot(t), eta__2_dot(t), u__2_dot(t)]:

nq := 15;            
xxUNDOT := [ seq ( xx[i], i = 1..nq),
             seq ( diff(xx[i],t), i = 1..nq)];
 

15

 

[x__s(t), y__s(t), u__s(t), x__r(t), y__r(t), u__r(t), x__c(t), y__c(t), u__c(t), zeta__1(t), eta__1(t), u__1(t), zeta__2(t), eta__2(t), u__2(t), diff(x__s(t), t), diff(y__s(t), t), diff(u__s(t), t), diff(x__r(t), t), diff(y__r(t), t), diff(u__r(t), t), diff(x__c(t), t), diff(y__c(t), t), diff(u__c(t), t), diff(zeta__1(t), t), diff(eta__1(t), t), diff(u__1(t), t), diff(zeta__2(t), t), diff(eta__2(t), t), diff(u__2(t), t)]

(1)

DOTL := [ seq ( xx[i], i = 1..nops(xx)) ]:
DOTR := [ seq ( xxUNDOT[i], i = 1..nops(xx))]:
Vector[column](DOTL),Vector[column](DOTR);

for i from nq+1 to nops(xx) do
newxx    := subs[inplace][eval](
  op(i,DOTL) = op(i,DOTR) ,xx):
end do:

Vector(30, {(1) = x__s(t), (2) = y__s(t), (3) = u__s(t), (4) = x__r(t), (5) = y__r(t), (6) = u__r(t), (7) = x__c(t), (8) = y__c(t), (9) = u__c(t), (10) = `ζ__1`(t), (11) = `η__1`(t), (12) = u__1(t), (13) = `ζ__2`(t), (14) = `η__2`(t), (15) = u__2(t), (16) = x__s_dot(t), (17) = y__s_dot(t), (18) = u__s_dot(t), (19) = x__r_dot(t), (20) = y__r_dot(t), (21) = u__r_dot(t), (22) = x__c_dot(t), (23) = y__c_dot(t), (24) = u__c_dot(t), (25) = `ζ__1_dot`(t), (26) = `η__1_dot`(t), (27) = u__1_dot(t), (28) = `ζ__2_dot`(t), (29) = `η__2_dot`(t), (30) = u__2_dot(t)}), Vector(30, {(1) = x__s(t), (2) = y__s(t), (3) = u__s(t), (4) = x__r(t), (5) = y__r(t), (6) = u__r(t), (7) = x__c(t), (8) = y__c(t), (9) = u__c(t), (10) = `ζ__1`(t), (11) = `η__1`(t), (12) = u__1(t), (13) = `ζ__2`(t), (14) = `η__2`(t), (15) = u__2(t), (16) = diff(x__s(t), t), (17) = diff(y__s(t), t), (18) = diff(u__s(t), t), (19) = diff(x__r(t), t), (20) = diff(y__r(t), t), (21) = diff(u__r(t), t), (22) = diff(x__c(t), t), (23) = diff(y__c(t), t), (24) = diff(u__c(t), t), (25) = diff(`ζ__1`(t), t), (26) = diff(`η__1`(t), t), (27) = diff(u__1(t), t), (28) = diff(`ζ__2`(t), t), (29) = diff(`η__2`(t), t), (30) = diff(u__2(t), t)})

(2)

Vector[column](newxx);

Vector(30, {(1) = x__s(t), (2) = y__s(t), (3) = u__s(t), (4) = x__r(t), (5) = y__r(t), (6) = u__r(t), (7) = x__c(t), (8) = y__c(t), (9) = u__c(t), (10) = `ζ__1`(t), (11) = `η__1`(t), (12) = u__1(t), (13) = `ζ__2`(t), (14) = `η__2`(t), (15) = u__2(t), (16) = x__s_dot(t), (17) = y__s_dot(t), (18) = u__s_dot(t), (19) = x__r_dot(t), (20) = y__r_dot(t), (21) = u__r_dot(t), (22) = x__c_dot(t), (23) = y__c_dot(t), (24) = u__c_dot(t), (25) = `ζ__1_dot`(t), (26) = `η__1_dot`(t), (27) = u__1_dot(t), (28) = `ζ__2_dot`(t), (29) = `η__2_dot`(t), (30) = diff(u__2(t), t)})

(3)

``


 

Download subs.mw

I tried to make a for loop that substitutes each variable one by one, but it only seems to work for the last term, I don't know why, please help or suggest another method? I also have diff(x__s,t,t) terms in my equations, not just diff(x__s,t), but I guess only by specifying the first derivate it should work?

 

Thanks.

 

I'm trying to program a procedure that will return me a list of positions defining equally spaced points (planets) around a circumference, for example:
PSI := [0, Pi]; # Location of 2 planets
PSI := [0, ((2/3)*Pi) , ((4/3)*Pi) ]; # For 3 Planets
I'm new to maple so most commands are new to me, I tried building the size of the list with [0 $ n] because I want the first position to always be at 0 degrees. The first problem is that I get this error:

Error, reserved word `for` unexpected

 

nplanets := 2;

2

(1)

make_PSI :=
proc(nplanets);
local n,psin,i,PSI:
n = nplanets;
psin  :=(pi*2)/n;
PSI := [0 $ n];
for i from 1 to n do
 angle :=(psin*i);
 op(i,PSI) := angle;
end do;
end;

 

 

Error, reserved word `for` unexpected

 


Any advice would be appreciated!

Download planetspace.mw

I've derived some system matrices from a equation which represents the dynamics of a mechanical system, I've searched for a way to convert this or represented in state space form but I can't figure out how to do it.

 

I'm still quite new to maple and I'm working calculating some dynamic equations.

I want to be able to selectively group certain variables or numbers depending on how I need the equations to be showed, I don't know if that's possible, I´ll explain further.

In typewritting extended format one equation is shown like this:

 

 

And maple standard:

 

The fisrt thing I want is to show the time derivatives in the dot representation, but I also want the 1/2 multiplyting each term of the whole equation like in the maoke standard format. 

I also need to group certain variables in some other equations I have and I was wondering if there is a way to do this.

1 2 Page 1 of 2