acer

32505 Reputation

29 Badges

20 years, 11 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

Would your Maple code still be valid and work as intended if you used .~ or perhaps *~ for the multiplcations in question? Or could you adjust it easily so that was the case?

If that holds then you may be able to extend the CodeGeneration[Matlab] translator so that those get translated to .* as Matlab syntax. (See here for some notes on that...).

Just an idea.

acer

What you've described seems similar to what I usually see. Ie, if I run cmaple.exe the Command Line Interface (CLI) under cygwin (a Unix-like environment for MS-Windows) then after an input syntax error the offending input is redisplayed and the cursor is positioned where Maple supposes that the error lies.

I can then use the right- and left-arrow keys to move the cursor, and the Backspace and Delete keys work, and it's in insert mode. So I can easily edit the input and make a correction.

The up- and down-arrow keys also step through my command history. The behaviour is much as if I were running the CLI under Linux or Unix. Ie, usual readline behaviour.

Alternatively, if I hit the Esc key (Escape) then the CLI maple prompt and input line respond to vi editor key bindings. I find this very handy.

The above works for me in the CLI under cygwin, and it doesn't seem to rely on whether I pass the `-u` option when invoking the CLI.

You didn't mention your OS. You didn't mention whether you are in fact using the CLI in a terminal window. If you are then does any of the above work for you?

acer

You could try running the Matlab[FromMFile] command against it.

Eg, if the original is in file "matin.txt" say,

Matlab[FromMFile]( "matin.txt", string );

or,

Matlab[FromMFile]( "matin.txt", "mapleout.mpl" );

where either those file names are changed to have their fully explicit paths or currentdir() has been called to set the location.

You may have to make a few edits to the original though, before doing that. You seem to be missing a second "end" for the double for-loop at the end of the code. Amd you may have to change the single backslashes "\" to double backslashes "\\" in the call to the Matlab `textread`.

The final result may need some work (you didn't supply the referenced data file so it's hard to test). But it may give you something to start with. You might wish to add "datatype=float[8]" to some of the resulting `rtable` constructor calls. And there may be other things to fix up.

The source is pretty simple. If you know basic syntax in both languages then you may find it easier to just write it manually.

acer

How about using GroupTheory:-Intersection from the GroupTheory package new to Maple 17?

(There is also group[inter] in the older group package.)

acer

Try the Programming Manual. There is a chapter on it. It has examples.

acer

Use a semicolon rather than a colon at the end of the command which would normally cause the plot to be displayed (ie. in this case the `plot3d` call).

acer

You can use so-called 2-argument `eval` for this.

eval( theta3, sol);

If the choice of variable names are changed then using `eval` in this way will be more robust then referring to some member of the set `sol` by position. For some other choice of variable names the position of the equation for `theta3` might be different (ie. not necessarily the 5th place).

acer

Import as datatype anything to Matrix M. The extract the column of interest, eg. V:=M[..,3] for the third column, say. Extract the column of M that you believe to contain floats.

At this point the entries of V are either all floats, or at least one is not. You wrote that the corresponding column in M does contain all floats. If that is true then so should V.

Then try executing Vector(V,datatype=float[8]) and if it produces an error message then post that here.

Other tests you might possibly find useful are,

type(V,'Vector(float)');

{seq(whattype(x), x in V)}; # could be slow

You wrote, "That fails since my data are now not floats." What was "that" operation that failed?

acer

If you only need a plot (reasonably) quickly, and only require the plotted function to be as accurate as is reasonably discernable by eye, then you can plot the numeric integral using relaxed accuracy requirements. Turning off adaptive plotting can also speed it up, but you may need to adjust the forced number of plotted points as the plotting range of the oscillatory function is increased.

The plot looks smoother in the Std GUI than is shown below. I lose resolution when exporting and uploading here. It doesn't take much longer, with keeping the adaptive plotting turned on.

To reduce the accuracy requirement I pass the epsilon=value option to evalf(Int(...)) , and so I rename your variable `epsilon` to `varepsilon` in order to avoid a naming conflict.

It's not strictly necessary to symbolically take the real part of your original integrand here, but it is a bit faster I think.

restart:  

igrand:=exp(I*epsilon*ln((2+t)/(2-t)))*exp(I*n*t)/sqrt(4-t^2)/Pi:
igrand:=simplify(evalc(Re(igrand))) assuming real, t>-2, t<2:            
newigrand:=subs(epsilon=varepsilon,igrand):                                  

ee:=Int(newigrand,t=-2..2,epsilon=1e-5,method=_d01ajc):                      

st:=time():
plot(eval(ee,[varepsilon=-0.4]),n=-10..10,adaptive=false,numpoints=100); 
time()-st;

                                 0.260

acer

restart:

v:=[seq(0.29+i/100,i=1..8)]:
k:=[seq(2*i,i=1..50)]*0.5*10^(-15):

M:=ExcelTools:-Import("data1.xlsx"):

plots:-surfdata(M, v[1]..v[nops(v)], k[1]..k[nops(k)]);

The `surfdata` command would accept Matrix(M) as well as listlist M, which would let you compare with calling `matrixplot`.

And of course you could just use 8 and 50 instead of nops(v) and nops(k). Or just use the first and last entries of your current v and k (and don't bother to construct either of those two lists unless you need them for something else...). Ie,

 

plots:-surfdata(M, v[1]..v[8], k[1]..k[50]);

plots:-surfdata(M, 0.3..0.37, 1e-15..5e-14);

and so on.

acer

Suppose that you have called dsolve/numeric without the option `listprocedure` and passed the result `sol` to plots:-odeplot, and obtained a warning about a singularity. Even though the warning itself cannot be trapped, you can still invoke `sol` at the farthest (rightmost, say, or "last") t=time point which you hoped to plot and get a trappable error.

For example, suppose that you wanted to plot from 0..1000 and have computed a result `sol` from dsolve,numeric which has a first singularity to the right of 0.0 occuring at approximately 701.02. After plotting, you can invoke,

p:=proc(dsn,val)
   try
      dsn(val); 
      "no singularity found";
   catch "cannot evaluate the solution further":
      eval(t,dsn('last'));
   end try;
 end proc:

> p(sol,500);
                            "no singularity found"

> p(sol,1000);
                               701.022570685642

Hence you can construct a programmatic mechanism for testing whether a singularity was hit, and what the value of the independent varaible `t` was. The technique is easy to adjust if you have used the output=listprocedure option.

What procedure `p` does is trap and manipulate a situation like this,

sol(1000):

Error, (in sol) cannot evaluate the solution further right of 701.02257,
probably a singularity

acer

Suppose that the Buttons have their Names as Button1, Button2...,Button6 and that the list of six values is `L`.

for i from 1 to 6 do
  DocumentTools:-SetProperty(cat(Button,i),'caption',L[i],'refresh'=true);
end do:

If you are planning on doing that repeatedly, for many different values in `L`, then you might consider assigning the button names to its own list and then accessing them without having to re-do the `cat` calls each time. Eg,

# do this just once
ButtonNameList := [seq(cat(Button,i), i=1..6)]:

# ...and then, for each different list of values L,
for i from 1 to 6 do
  DocumentTools:-SetProperty(ButtonNameList[i],'caption',L[i],'refresh'=true);
end do:

acer

Try it with,

   sprintf("C:\\Users\\Sorted_Eigenvectors_%d.txt",i)

as that first argument to ImportMatrix.

acer

With a little extra work, yes. See here for a couple of ways (or varying efficiency vs ease).

acer

Maple 17 does this.

BesselI(0,I*x);

                         BesselJ(0, x)

It's also done in Maple 12 and Maple 14. I didn't try others. Which version do you have?

acer

First 250 251 252 253 254 255 256 Last Page 252 of 337