acer

32587 Reputation

29 Badges

20 years, 37 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by 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

Your code uses `int`, and `is` which are not thread-safe.

btw, it's very inefficient to have that call to `unapply` be inside the for-do-loop.

acer

Maybe it is related to 0 as the lower index value on the Sum.

> T:=1/(6*0+1)!+Sum(1/(6*k+1)!, k=1..infinity):

> evalf(T);

                                  1.000198413

> simplify(combine(radnormal(value(T))));

    /                   1/2                  1/2
    | 1/2              3                    3
1/6 |3    exp(3/2) sin(----) + exp(3/2) cos(----) + exp(2)
    \                   2                    2

                          1/2                  1/2     \
        1/2              3                    3        |
     + 3    exp(1/2) sin(----) - exp(1/2) cos(----) - 1| exp(-1)
                          2                    2       /

> evalf(%);

                                  1.000198414

acer

First 251 252 253 254 255 256 257 Last Page 253 of 338