Joe Riel

9660 Reputation

23 Badges

20 years, 14 days

MaplePrimes Activity


These are replies submitted by Joe Riel

You have to adjust the indices (if you'll look at my original response, you'll note that there was a comment about that).  That is, you don't want to stop at the lowest index (r) if you are attempting to access L[r-1].  Instead, you have to stop at r+1.  Similarly when looping in the other direction.

That was why I had suggested

rng := rtable_dims(A);
start := lhs(rng);
finish := rhs(rng);

That assigns start/finish the initial and final indices of the rtable.  You could also use ?rtable_num_elems, however, that doesn't provide enough information if the rtable doesn't start at a known index.

That was why I had suggested

rng := rtable_dims(A);
start := lhs(rng);
finish := rhs(rng);

That assigns start/finish the initial and final indices of the rtable.  You could also use ?rtable_num_elems, however, that doesn't provide enough information if the rtable doesn't start at a known index.

Try this,

with(DynamicSystems):
sys := TransferFunction(1/(1+s)):
plts := BodePlot(sys, output=[magnitudeplot,phaseplot]):
plots:-display(Vector(plts));

You can create your own bodeplot procedure to do that automatically:

bodeplot := proc()
   plots:-display(Vector(DynamicSystems:-BodePlot(args, 'output=[magnitudeplot,phaseplot]')));
end proc:

I'm sorry, but I don't know how to interpret "in force".  Maybe you could attempt to rephrase that. 

Using mu(x,theta) for the axial-coordinate won't generate a cylinder, mu is periodic in theta. 

I'm sorry, but I don't know how to interpret "in force".  Maybe you could attempt to rephrase that. 

Using mu(x,theta) for the axial-coordinate won't generate a cylinder, mu is periodic in theta. 

Actually, would you rather have both graphs in one plot, say with the magnitude using the left-axis and the phase the right-axis?  Dual-axis plots weren't possible when ?DynamicSystems was released, but are now and that should be added as an option.  To do that now, do

with(DynamicSystems):
sys := TransferFunction(1/(1+s)):
plts := BodePlot(sys, output=[magnitudeplot,phaseplot]):
plotsetup(maplet); # only needed if not in Standard
plots:-dualaxisplot(plts[]);

 

Arrgggh.  Don't convert L to a list.  Leave it as an rtable.

The problem with your loop is that they are, essentially,

for j from 6 to 1 do ... end do;

That does nothing because the default step size is +1; you need to use the ?by keyword to set a negative step:

for f from 6 to 1 by -1 do ... end do;

 

Arrgggh.  Don't convert L to a list.  Leave it as an rtable.

The problem with your loop is that they are, essentially,

for j from 6 to 1 do ... end do;

That does nothing because the default step size is +1; you need to use the ?by keyword to set a negative step:

for f from 6 to 1 by -1 do ... end do;

 

To go backwards, use the by keyword in a for-loop, for example,

for i from 5 to 1 by -1 do
    ...
end do;

Rather than code a procedure for you, I'll give you a few suggestions.

Write a procedure that operates on an Array in-place:

cocktailsort := proc(A) ... end proc:

Use ?rtable_dims to extract a range that corresponds to the dims of A.  Then use ?lhs and ?rhs to extract the min and max values:

rng := rtable_dims(A);
start := lhs(rng);  # you may have to adjust these values depending on how you code the loops.
finish := rhs(rng);

To swap two elements, do

(A[i], A[i+1] ) := (A[i+1], A[i]);

 

 

To go backwards, use the by keyword in a for-loop, for example,

for i from 5 to 1 by -1 do
    ...
end do;

Rather than code a procedure for you, I'll give you a few suggestions.

Write a procedure that operates on an Array in-place:

cocktailsort := proc(A) ... end proc:

Use ?rtable_dims to extract a range that corresponds to the dims of A.  Then use ?lhs and ?rhs to extract the min and max values:

rng := rtable_dims(A);
start := lhs(rng);  # you may have to adjust these values depending on how you code the loops.
finish := rhs(rng);

To swap two elements, do

(A[i], A[i+1] ) := (A[i+1], A[i]);

 

 

I frequently run tasks in the background, so additional CPU usage will just slow them down.  However, I don't write books in the worksheet interface...

I tried it with Maple 13.02 on 64 bit linux, with an I5  and could get brief periods of usage near 44% (on one core).  On a P4 with 32 bit linux I could get get similar percentages. This is just typing text, with no returns.

A similar hack is to use the empty function to group the terms:

X3 := -((N1*X1*e2 + N2*X2*e1)*e3) / (e1*e2*N3):
algsubs(e3/e1/e2=``(e3/e1/e2), X3); 
                                              e3
                                            (-----) (N1 X1 e2 + N2 X2 e1)
                                             e1 e2
                                         - ------------------------------
                                                         N3

A call to expand evaluates the empty function call to its argument.

Something I frequently wish for is a built-in identity function.  Then one could do

algsubs((Id=``)(e3/e1/e2), X);

which seems nicer. Id := ()-> args works, but I'd prefer a builtin.

A similar hack is to use the empty function to group the terms:

X3 := -((N1*X1*e2 + N2*X2*e1)*e3) / (e1*e2*N3):
algsubs(e3/e1/e2=``(e3/e1/e2), X3); 
                                              e3
                                            (-----) (N1 X1 e2 + N2 X2 e1)
                                             e1 e2
                                         - ------------------------------
                                                         N3

A call to expand evaluates the empty function call to its argument.

Something I frequently wish for is a built-in identity function.  Then one could do

algsubs((Id=``)(e3/e1/e2), X);

which seems nicer. Id := ()-> args works, but I'd prefer a builtin.

First 103 104 105 106 107 108 109 Last Page 105 of 195