tomleslie

13876 Reputation

20 Badges

15 years, 170 days

MaplePrimes Activity


These are answers submitted by tomleslie

restart;
getfun:= rsolve( { a(n)=-3*a(n-1)+a(n-2),
                            a(0)=7,
                            a(1)=2
                         },
                         a(n),
                        `makeproc`
                      ):
seq( getfun(n),
     n=0..10
   );

 

The Excel Add-In is essentially used to access Maple commands from within Excel, not to tranfer data from Excel to Maple

If you want to import data from an Excel spreadsheet to Maple, then use the ExcelTools:-Import() function from within Maple and supply appropriate entries for the Excel fileName, the sheetName within the Excel file and the cellRange within the sheet.

Check the help with ?ExcelTools

You have three first order differential equations. In order to solve these completely, you need three initial conditions - where are these ICs?

In the line

deltau__doubledot[i,j]:= 40000*deltau[i,j]-400*u__dot[i,j]-(2*u__doubledot[i.j]):

did you really mean 2*u__doubledot[i.j] rather than 2*u__doubledot[i,j]

ie a 'period' rather than a 'comma' in the index specification

 

The easiest(?) way is to wrap the actual calculation in a Maple proceure, then call that procedure with the required values of the parameter R - as in the attached.

In the attached version I have changed a couple of variable names to avoid error messages

The last command in the attached evaluates/plots the desired quantity for R=100..1000, in steps of 100, and takes about 80secs to run (on my machine). I have made no attempt to make the actual calculation run faster:-(

rotation.mw

AFAIK there is no way to define a list in Maple such that it is 'readonly'.

One could probably 'spoof' the idea of a 'readonly list' by using a Vector() with option readonly=true, although this would probably require a lot of convert() statements, if it is to be used in any expression whose arguments are required to be lists

I do hope that this question is not related to your previous question, where assignment to matrix entries caused a problem. You might want to carefully consider the difference between assigning to a matrix element (possibel with a 'readonly' matrix), and changing a matrix element (not possible with a 'readonly' matrix). Check the output of the following code carefully

   restart;
#
# Set matrix as readonly, then reassign an element
#
   A := Matrix([[x, y], [z, t]], readonly=true);
   x:=1;
   A;
#
# Set matrix as readonly, then try to change an element
#
   restart;
   A := Matrix([[x, y], [z, t]], readonly=true);
   A[1,1]:=p;

 

 

If you are using the same procedures in mutliple worksheets, then probably the best way (and one which I use most often) is to develop the procedures externally (in plaintext) in your favourite text editor, save them with a '.mpl/ extension, and then use a 'read' statement in any worksheet where they are desired. Notice than you can have multiple procedures in a single '.mpl' file, or have each procedure in its own .mpl file. I tend to use the latter - but that is just a personal preference

In your specific case, a viable alternative, would be to save the required procedures from the originating worksheet in '.mw' format, just by adding a 'save' satement in that worksheet. This is basically a way of saving simple assignments from a worksheet for use elsewhere,  (and a procedure is a simple assignment).

Consider the 'toy' example of a worksheet such as

doSqrt:= proc(x)
                         return sqrt(x)
                end proc;
doSin:= proc(x)
                        return sin(x)
              end proc;
plot([doSqrt, doSin], 0..2*Pi);
save doSin, doSqrt, "C:/Users/TomLeslie/Desktop/someProcs.mw";

where the last command will save the procedures 'doSin', 'doSqrt' to a '.mw' file.

Then, in a completely new worksheet, one could have

read "C:/Users/TomLeslie/Desktop/someProcs.mw";
plot([doSqrt, doSin], 0..2*Pi);

which will read the procedures, and obvously allow execution

So many ways to do the same thing - you just have to decide which is more appropriate for you

Plot provided by rlopez' approach is mathematically correct - because the vertical line at 2 does not *really* exist.

However you can persuade Maple to plot the (non-existent) vertical line by ensuring that points of dicontinuiity appear in the sample list option, as in

   g:=piecewise(x<2,x-1,x=2,2,x>=2,2-x):
   plot(g, x=0..3, sample=[seq(j, j=0..3,0.01)]);

 

  1. Why do you have 100 subsections - seems like a really badly constructed worksheet
  2. The menu entry View->Sections->Collapse All Sections would seem to perform the action you require

Set a breakpoint,

See either ?DEBUG or ?debugger depending on how complicated you want to get

Use the big green up-arrow in the Mapleprimes toolbar to upload a worksheet

In the attached, I have made two changes to your original

  1. In the 'return' statement of the procedure KilicInv(), I changed eval(ainv) to simplify(ainv). This will return the simplified version of ainv, (in particular ain[1,1]), whether or not you make the following change
  2. In the Test rig, I changed the definitions of delta, mu to assignments. With your original code, the [1,1] elements displayed are expressions involving 'a', 'mu', 'delta'. With this revision, the [1,1] displayed elements are expressions involving 'a' only

My changes are highlighted in the following

compareInvers.mw

 

Standard copy/paste (CTRL-C, CTRL-V) works for me, so I'm not sure why you should have a problem.

Since you do have a problem, then just "export" the matrix from the source worksheet and then "import" into the target worksheet. For example,

code in source worksheet

with(LinearAlgebra):
M:=RandomMatrix(20,20);
ExportMatrix( "C:/Users/TomLeslie/Desktop/testmat.mpl", M);

Code in target worksheet

M:=ImportMatrix( "C:/Users/TomLeslie/Desktop/testmat.mpl");

works for me

 

 

I don't think you can fix this in Maple

On the other hand any decent editor with a 'regexp' engine will fix the output files. The regexp search string would need to be

\\+

The first backslash character just "escapes" the special meaning of second backslash character, so the above essentially means - find one or more instances of the character \

Then the regexp substitution string would be \\ - where again the first backslash just escapes the second backslash as a special character

I have just tried this in emacs, where it obviously works, cos the emacs regexp engine is pretty good. However it also works in Notepad++, where (I must admit) I rarely/never use the regexp capability. I'm not criticisng Notepad++ - just when I think that regexps are going to be necessary, I tend to go for either emacs or perl

I used a similar(ish) approach to that given by acer, namely

restart;
interface(rtablesize=12);
with(StringTools):
M:=Import("C:/Users/TomLeslie/Desktop/foo.txt", format="CSV", output=Matrix);

However I hit a problem when trying to parse the embedded strings to some kind of Maple expression with the function

f:=x->`if`( type(x, string),
                parse(x),
                x
              )
:

For the example you give, this works for the first seven entries of the Matrix M, with

f~(M[1,1..7]);

However this parsing fails on the 8-th entry, because "\frac{x^3}{3}" does not parse to a meaningful Maple expression - not sure how you are going to deal with this :-(

First 168 169 170 171 172 173 174 Last Page 170 of 207