tomleslie

13876 Reputation

20 Badges

15 years, 169 days

MaplePrimes Activity


These are replies submitted by tomleslie

@Bendesarts 

So when you say

But, I think that slight modifications on the calculation of the vertical space vSpace should be conducted.

and I provide the relevant calculation - which your latest worksheet ignores, I'm now supposed to fix some other, unrelated problem????

What this particular thread has shown me is

  1. You have no idea what you want
  2. You have no idea how to achieve it
  3. When given specific information, you ignore it
  4. Given all of the above, you still expect people to respond

I don't really understand you latest question (either I am stupid or you are - pick one). My time is too valuable for further responses so if the following isn't the answer.....

GaitPlot_Again.mw

You have chosen to adopt a coding style which makes debugging very difficult. If I attemto to execute your code "as is" then Maple produces an output window - I assume asking me to make a choice becuase your code is ambiguous. However this windo is so big that I cannot see the choices at the bottom aan have to terminate Maple using CTRL-alt-delete.

If I do a little hacking to put you code in a sensible form (primarily using 1-D input, and splitting it into separate execution groups - see Carl's comment earlier) then I can detect a number of suspicious occurrences which may or may not be errors.

The definition of Q in 1-D form is

Q:=a1*(phi(x,t)-diff(w(x,t),x))-a2*(diff(phi(x,t),x,x)) -a3*(diff(w(x,t),x$3)) +a4*(diff(phi(x,t),x$4))+a5*(diff(w(x,t),x$5))+(m2+-2 c1*m4+c1^(2)*m6)*(diff(phi(x,t),t$2)) +( c1*m4-c1^(2)*m6)*diff(w(x,t),x,t,t):

where I have highlighted the syntax error which makes Maple barf - it really does not like the +- combination. I have no idea what the 2-D parser does with this, but the ambiguity should be removed

The definition of phi(x,t) is

phi(x,t):=Phi(x)*(e)^(I*omega*t);

Using 2-D input this is ambiguous, but the parser probably gives you some option about whether you want this to be interpreted as a function definition or a remember table reference and you can select the "appropriate" option. Don't do this. If you have to use 2-D input, then at least write unambiguous code, which I suspect would be

phi:=(x,t)->Phi(x)*(e)^(I*omega*t);

Having removed the function definition ambiguity, I am pretty sure that this is still wrong because you actually mean this definition to be

phi:=(x,t)->Phi(x)*exp(I*omega*t)

In Maple if you want the exponential function, you have to use exp(), not e^.

Very similar arguments apply to the statement

w(x,t):=W(x)*(e)^(I*omega*t);

which almost certainly(?) should be

w:=(x,t)->W(x)*exp(I*omega*t);

The definition of func[1] is

func[1]:=(collect(Q,exp(I*omega*t)))/((e)^(I omega t))

Not only does this have the same e/exp() problem as mentioned earlier, but I'm guessing that there is a misuse of the2-D input mode's implied multiplication capability. I'm pretty sure that the exponent in the denominator should have multilplication symbols, so that the definition of of func[1] should be

func[1]:=collect(Q,exp(I*omega*t)))/exp(I*omega*t))

A more-or-less identical problem affects the definition of func[2]

At this point I got bored and gave up fixing basic syntax

 

@Preben Alsholm 

I'm not a big fan of Units, because whenever I have tried to use it in what I consider to be a "logical" and "sensible" manner, something usuually breaks:-( For example in the OP's differential equation, something like the following seems reasonably sensible

R := 500*Unit(ohm);
C := .5*Unit(microfarad);
V := 20*Unit(volt);
ode := R*diff(q1(t*Unit(second) ), t*Unit(second))*Unit(coulomb)+q1(t*Unit(second))*Unit(coulomb)/C = V;

However this just leads to a lot of error messages from dsolve(). If you have any idea how to define this equation in such a way that 't' has units of seconds, 'q(t)' has units of coulombs, and the ode is solved with the resut being displayed with the correct units, then I would be delighted to know how it is done - cos I can't persuade Maple to do it

You can put it anywhere you want, provided you give a full path name to the read command.

The read() command with just a filename (ie no path), will only search your current working diirectory, which could be anywhere, depending on how you installed/configured Maple to work, whether you have a userprofile set up, etc.

Since I have no idea of your particular installation/configuration, or how you like to work, I really cannot advise on a suitable place to put this file - but a full pathname will always work!

I should also have made it clear than since you have an mpl file rather than a Maple archive (mla) loading/enabling this package is a two-stage process: you need read(); followed by with(). Only the read() command needs the full path to the DEsolv.mpl file

I'm guessing that you have a problem finding the DEsolv.mpl file. Try providing a full path name to this file in the read() command: otherwise Maple will only look in your "current working directory", [ returned by currentdir() ]

I was referring to fact that I was guessing what you actually wanted. When I guess - I often guess wrong - so it is often "not a good idea" for me to make the guess

Still not completely sure why you want to save as a string (unless you want to export the line somewhere else??)

BTW I should have mentioned that the character you referred to , ie ||, is in fact Maple's concatenation operator: this helps to explain the output you originally obtained - which now seems to have disappeared(??)

From the help page for cat()

Functions are not converted to strings, rather || structures are returned.
cat( "a", b() );

will return

"a" || (b())

Assuming that I can guess what you actually want (never a good idea on my part) then you could try

restart:
eq:=phi(f(x,y(x),diff(y(x),x)),g(x,y(x),diff(y(x),x)));
r := cat("dsolve(",convert(eq, string),",y(x)");

Why doesn't the following work?

   restart;
#
# Define some function y()
#
    y:=z -> z^2*sin(z);
#
# Generate Taylor series about the point,
# x=0, retaining only the first three terms
# and convert the result to a polynomial
#
   convert(taylor(y(x+h), x=0, 3), polynom);

I changed the way vSpace is calculated to cater for the fact that the waveform amplitudes are now about the 1/10th of previous values - the method in the attached *ought* to be OK for almost any amplitudes

I made numerous other minor changes

GaitPlot5.mw

From my experience of using both Matlab and Maple, the plotting capabilities are pretty similar, so I would be very doubtful that simply transferring the data to matlab would be of any benefit.

Perhaps if you supply the Maple code/plots and explain what you think is wrong with the latter, then someone might be able to help

If you really really want to export to Matlab then the first thing you have to ask youself is whether you want to export the plot data, or the equations(?) which producee the data: either is possible.

I set up the spacing betwen v[i](t) and v[i+1](t) ofn the basis of computing the maximum of the former and the minimum of the latter: once you know these two numbers then working out the required spacing (ie offset) required between these two curves is trivial. It requires no knoiwledge of the input parameters for your oscillator or "adding a coefficient" to get a good plot.

Since you choose to ignore my working solution, in favour of your own which doesn't work very well, I feel no obligation to fix anything. Try supplying a copy of gaitPlot4.mw where only the input parameters have changed - and my solution doesn't work: then I might think about it: otherwise I won't.

Similarly in gaitPlot4.mw, I calculated a whole sequence of values for each of v[i](t): from this data, it is relatively trivial to work out a pretty good approximation to the zero-crossings (with a little bit of interpolation, if necessary). Once the t-values of the zero crossings are known, plotting vertical lines at these points is again trivial

I meet another problem. When I change the parameters of the NL oscillator, I need to adapt the term in bold in the following equation:

p1:= plots:-odeplot(res,[seq([t,v[i](t)+(i-1)*5],i=1..4)],0..tmax,thickness=2, view=[0..5, -1..16], numpoints = numpts):

The only thing which the highligeted term is controlling is the vertical spacing between between the curves v1(t), v2(t) etc. If you change the oscilator parameters so that the amplitudes of v1(t), v2(t) etc increase (or decrease), then the vertical spacing between them will have to be increased (or decreased) to keep the resulting plot looking "nice". The easiest way is probably to work with the maximum/minimum values of these functions. One possibility is shown in the attached worksheet, although since I have no idea what parameters of the oscillator you will change and what impact this will have on the amplitudes of the waveforms, I cannot really test it. I'm good, but I'm not psychic!

gaitPlot4.mw

As for the issue of annotating plots, I suggest that create a textplot() - see the manual. This will allow you to place any text/values at any location. Since you *know* the spacing between curves (see above) and the max/min values on each curve, you should be able to work out the coordinates for any text/values fairly easily. Having created an appropriate textplot() of any text/values you want, at any coordinates you want (none of which I know), the all you have to do is add this textplot to the final plots:-display list

To solve your first problem, simply add the option axes=boxed to the plots[display] command, as in

plots[display]([p1, seq([la||j, lb||j][], j=1..4)],
                     tickmarks=[default, [0=0, 5=0, 10=0, 15=0]],
                     axes=boxed
                  );

If I understand your second question correctly, then I think you have two choices

  1. Right click on the final graph, go to probe Info - Nearest point on line\: then just move cursor over the graph and (x,y) values should appear
  2. The above is a pretty crude way to analyse the resulting graphs. A better (more analytic way) would be to generate a list of values for (say) v1(t), over a least one period - one can then use max() or min() on this list. For v1(t) (which is actually rhs(res[6]) ) the max/min code would look like

vvals:=seq(rhs(res[6])(j),j=0..1,0.0001):
max(vvals);
min(vvals);

I have implemented both of the above changes in the attached

gaitPlot3.mw

I have no idea what

I have a worksheet that makes 38 Mo

means! 38Mb I understand, 38MB I understand, but 38Mo is meaningless to me.

Similarly, I have no idea what a "heavy" worksheet is - I assume that we are having a language problem

Before you save the file, use the menu entry Edir->Remove Output->From Worksheet. Ths should ensure that all you save is the "input|" code

First 165 166 167 168 169 170 171 Last Page 167 of 207