Contents Previous Next Index
11 Input, Output, and Interacting with Other Products
11.1 In This Chapter
Writing to Files - Saving to Maple file formats
Saving Data to a File
Saving Expressions to a File
Reading from Files -Opening Maple files
Reading Data from a File
Reading Expressions from a File
Exporting to Other Formats - Exporting documents in file formats supported by other software
Connectivity - Using Maple with other programming languages and software
Translating Maple Code to Other Programming Languages
Accessing External Products from Maple
Accessing Maple from External Products
Sharing and Storing Maple Worksheet Content with the MapleCloudTM
11.2 Writing to Files
Maple supports file formats in addition to the standard .mw file format.
After using Maple to perform a computation, you can save the results to a file for later processing with Maple or another program.
Note: Make sure you have right access to the directory in order to execute the example in the following subsections.
If the result of a Maple calculation is a long list or a large array of numbers, you can convert it to Matrix form and write the numbers to a file using the ExportMatrix command. This command writes columns of numerical data to a file, allowing you to import the numbers into another program. To convert a list or a list of lists to a Matrix, use the Matrix constructor. For more information, refer to the Matrix help page.
If the data is a Vector or any object that can be converted to type Vector, use the ExportVector command. To convert lists to Vectors, use the Vector constructor. For more information, refer to the Vector help page.
You can extend these routines to write more complicated data, such as complex numbers or symbolic expressions. For more information, refer to the ExportMatrix and ExportVector help pages.
For more information on matrices and vectors, see Linear Algebra.
If you construct a complicated expression or procedure, you can save them for future use in Maple. If you save the expression or procedure in the Maple internal format, Maple can retrieve it more efficiently than from a document. Use the save command to write the expression to a .m file. For more information on Maple internal file formats, refer to the file help page.
In this example, small expressions are used. In practice, Maple supports expressions with thousands of terms.
You can save these expressions to the file qbinom.m.
save qbinomial, expr, nexpr, qbinom.m
Clear the memory using the restart command and retrieve the expressions using the read command.
For more information on writing to files, refer to the save help page.
Saving Data as Part of a Workbook
You can save all files related to a common Maple project as a workbook (.maple) file. Saving your data files and worksheets (or documents) as a workbook allows you to use this saved data across all .mw file inside your workbook.
11.3 Reading from Files
The most common reason for reading files is to load data, for example, data generated in an experiment. You can store data in a text file, and then read it into Maple.
Import Data Assistant
If you generate data outside Maple, you can read it into Maple for further manipulation. This data can be an image, a sound file, or columns of numbers in a text file. You can easily import this external data into Maple using the Import Data Assistant, where the supported file formats include files of type Excel®, MATLAB®, Image, Audio, Matrix Market, and Delimited.
To launch the Import Data Assistant:
From the Tools menu, select Assistants, and then Import Data.
A dialog window appears where you can navigate to your data file. Select the file that you want to import data from, and then select the file type before clicking Next.
From the main window, you can preview the selected file and choose from the applicable options based on the format of the file read in before importing the data into Maple. See Figure 11.1 for an example.
Figure 11.1: Import Data Assistant
The Import Data Assistant provides a graphical interface to the ImportMatrix command. For more information, including options not available in the assistant, refer to the ImportMatrix help page.
You can write Maple programs in a text file using a text editor, and then import the file into Maple. You can paste the commands from the text file into your document or you can use the read command.
When you read a file with the read command, Maple treats each line in the file as a command. Maple executes the commands and displays the results in your document but it does not, by default, insert the commands from the file in your document.
For example, the file ks.txt contains the following Maple commands.
S:= n -> sum( binomial( n, beta ) * ( ( 2*beta )! / 2^beta - beta!*beta ), beta=1..n );
Note that the file should not contain prompts (>) at the start of lines.
When you read the file, Maple displays the results but not the commands.
filename≔catkerneloptsdatadir,kerneloptsdirsep,ks, kerneloptsdirsep, ks.txt:
If you set the interface echo option to 2, Maple inserts the commands from the file into your document.
interfaceecho=2: read filename
> S:= n -> sum( binomial( n, beta ) * ( ( 2*beta )! / 2^beta - beta!*beta ), beta=1..n );
For more information, refer to the read and interface help pages.
Reading Data From Workbook Attachments
Data stored in a workbook in the form of an attachment, can be accessed easily using the workbook URI. For information on workbook attachments, see worksheet,workbook,attachFiles. For information on the workbook URI format, see worksheet,workbook,uri.
11.4 Exporting to Other Formats
You can save your documents by selecting Save or Save As from the File menu. By selecting Export As from the File menu, you can also export a document in the following formats: HTML, LaTeX, Maple input, Maplet application, Maple text, plain text, PDF, and Rich Text Format. This allows you to access your work outside Maple.
The .html file that Maple generates can be loaded into any HTML browser. Exported mathematical content can be displayed in one of the following formats: GIF, MathML 2.0 Presentation, MathML 2.0 Content, or Maple Viewer, and is saved in a separate folder. MathML is the Internet standard, sanctioned by the World Wide Web Consortium (W3C), for the communication of structured mathematical formulae between applications. For more information about MathML, refer to the MathML help page.
Maple documents that are exported to HTML translate into multiple documents when using frames. If the frames feature is not selected, Maple creates only one page that contains the document contents.
The .tex file generated by Maple is ready for processing by LaTeX. All distributions of Maple include the necessary style files. By default, the LaTeX style files are set for printing the .tex file using the dvips printer driver. You can change this behavior by specifying an option to the \usepackage LaTeX command in the preamble of your .tex file. For more information, refer to the exporttoLaTeX help page.
You can export a Maple document as Maple input so that it can be loaded using the Maple Command-line version.
Important: When exporting a document as Maple input for use in Command-line Maple, your document must contain explicit semicolons in 1-D Math input. If not, the exported .mpl file does not contain semicolons, and Command-line Maple generates errors.
The Export as Maplet facility saves a Maple document as a .maplet file, so that you can run it using the command-line interface or the MapletViewer. The MapletViewer is an executable program that can launch saved Maplet applications. It displays and runs Maplet applications independently of the Maple Worksheet interface.
Important: When exporting a document as a Maplet Application for use in Command-line Maple or the MapletViewer, your document must contain explicit semicolons. If not, the exported .maplet file does not contain semicolons, and Command-line Maple and the MapletViewer generates errors.
Maple text is marked text that retains the distinction between text, Maple input, and Maple output. Thus, you can export a document as Maple text, send the text file by email, and the recipient can import the Maple text into a Maple session and regenerate the computations in the original document.
Export a Maple document to a Portable Document Format (PDF) file so that you can open the file in a reader such as Adobe® Acrobat®. The PDF document is formatted as it would appear when the Maple worksheet is printed using the active printer settings.
Note: Images, plots, and embedded components may be resized in the PDF file.
Export a Maple document as plain text so that you can open the text file in a word processor.
Rich Text Format (RTF)
Export a Maple document to a rich text format file so that you can open and edit the file in a word processor.
Note: The generated .rtf format is compatible with Microsoft Word and Microsoft WordPad only.
Summary of Translation
Rich Text Format
Preceded by #
Preceded by >
GIF or MathML
1-D Math or LaTeX 2e
1-D Math (if possible)
1-D Math or character-based typesetting
Either text or shapes depending on option selected
Manually inserted page break
RTF page break object
Links to help pages become plain text. Links to documents are renamed and converted to HTML links
Embedded image or sketch output
Approximated by HTML style attributes
LaTeX environments and sections, LaTeX 2e macro calls
Overview of MapleNet
Using MapleNet, you can deploy Maple content on the web. Powered by the Maple computation engine, MapleNet allows you to embed dynamic formulas, models, and diagrams as live content in web pages. The MapleNet software is not included with the Maple software. For more information on MapleNet, visit http://www.maplesoft.com/maplenet.
MapleNet Documents and Maplets
After you upload your Maple document to the MapleNet server, it can be accessed by anyone in the world using a web browser. Even if viewers do not have a copy of Maple installed, they can view documents and Maplets, manipulate 3-D plots, and execute code at the click of a button.
Custom Java Applets and JavaServer PagesTM Technology
MapleNet provides a programming interface to the Maple math engine so commands can be executed from a Java applet or using JavaServer PagesTM technology. Embed MapleNet into your web application, and let Maple handle the math and visualization.
Translating Maple Code To Other Programming Languages
The CodeGeneration package is a collection of commands and subpackages that enable the translation of Maple code to other programming languages. Languages currently supported include: C, C#, Fortran 77, Java, MATLAB®, Visual Basic, Perl, and Python.
For details on Code Generation, refer to the CodeGeneration help page.
External calling allows you to use compiled C, C#, Fortran 77, or Java code in Maple. Functions written in these languages can be linked and used as if they were Maple procedures. With external calling you can use pre-written optimized algorithms without the need to translate them into Maple commands. Access to the NAG library routines and other numerical algorithms is built into Maple using the external calling mechanism.
External calling can also be applied to functions other than numerical algorithms. Routines exist that accomplish a variety of non-mathematical tasks. You can use these routines in Maple to extend its functionality. For example, you can link to controlled hardware via a serial port or interface with another program. The Database package uses external calling to allow you to query, create, and update databases in Maple. For more information, refer to the Database help page.
For more information on using external calling, refer to the ExternalCalling help page.
The MmaTranslator package provides translation tools for converting Mathematica® expressions, command operations, and notebooks to Maple. The package can translate Mathematica input to Maple input and Mathematica notebooks to Maple documents. The Mma subpackage contains commands that provide translation for Mathematica commands when no equivalent Maple command exists. In most cases, the command achieves the translation through minor manipulations of the input and output of similar Maple commands.
Note: The MmaTranslator package does not convert Mathematica programs.
There is a Maplet interface to the MmaTranslator package. For more information, refer to the MmaToMaple help page.
The Matlab package enables you to translate MATLAB® code to Maple, as well as call selected MATLAB® functions from a Maple session, provided you have MATLAB® installed on your system.
For more information, refer to the Matlab help page.
Microsoft Excel Add-In
Maple is available as an add-in to Microsoft Excel. This add-in is supported for Excel 2016, Excel 2013, and Excel 2010 for Windows, and provides the following features.
Access to Maple commands from Excel
Ability to copy and paste between Maple and Excel
Access to a subset of the Maple help pages
Maple Function Wizard to step you through the creation of a Maple function call
To enable the Maple Excel Add-in in Excel 2010, Excel 2013, and Excel 2016:
In Excel, click the File menu and select Options.
In the Manage box select Excel Add-ins, and then Go.
Navigate to the Excel subdirectory of your Maple installation and select the appropriate file:
For 32-bit Windows, select WMIMPLEX.xla (that is, select $MAPLE/Excel/WMIMPLEX.xla), and click OK.
For 64-bit Windows, select WMIMPLEX64.xla (that is, select $MAPLE/Excel/WMIMPLEX64.xla), and click OK.
Select the Maple Excel Add-in check box.
For further details on enabling the Maple Excel Add-in, refer to the Excel help page.
For information on using this add-in, refer to the Using Maple in Excel help file within Excel.
To view this help file:
Enable the add-in.
From the View menu, select Toolbars, and then Maple.
On the Maple toolbar, click the Maple help icon
OpenMaple is a suite of functions that allows you to access Maple algorithms and data structures in your compiled C, C#, Java, or Visual Basic programs. (This is the reverse of external calling, which allows access to compiled C, C#, Fortran 77, and Java code from Maple.)
To run your application, Maple must be installed. You can distribute your application to any licensed Maple user. For additional terms and conditions on the use of OpenMaple, refer to the extern/OpenMapleLicensing.txt file in your Maple installation.
For more details on using OpenMaple functions, refer to the OpenMaple help page.
MapleSimTM is a complete environment for modeling and simulating multidomain engineering systems. During a simulation, MapleSim uses the symbolic Maple computation engine to generate the mathematical models that represent the system behavior.
Because both products are tightly integrated, you can use Maple commands and technical document features to edit, manipulate, and analyze a MapleSim model. For example, you can use Maple commands and tools to manipulate your model equations, develop custom components based on a mathematical model, and visualize simulation results.
MapleSim software is not included with the Maple software. For more information on MapleSim, visit http://www.maplesoft.com/maplesim.
MaplePlayer for iPad
The Maple Player is a free application for the iPad that uses the Maple computation engine to enable you to view and interact with documents created in desktop Maple.
For more information on the Maple Player for iPad, visit http://www.maplesoft.com/products/MaplePlayer.
Sharing and Storing Maple Content
You can use the MapleCloud to share or store your Maple documents and workbooks. Upload Maple documents or workbooks. Package workbooks offer a way to share a Maple packages with other users, including source code, documentation and examples.
The MapleCloud has private and public sharing. You can share with all Maple users, share with a private group, or upload and store content in a user-specific area that only you can access.
Users need an internet connection to use the MapleCloud. Anyone can access publicly shared documents. To share content, create, manage and join user groups; and view group-specific content, you must log in to the MapleCloud using a Maplesoft.com, Gmail™, or Google Mail™ account name and password.
A Maplesoft.com membership account gives you access to thousands of free Maple resources and MaplePrimes, which is an active web community for sharing techniques and experiences with Maple and related products. To sign up for a free Maplesoft.com membership account, visit http://www.maplesoft.com/members/sign_up_form.aspx. The MapleCloud is integrated with several of these online features, so it is strongly recommended that you use a Maplesoft.com membership account.
For more information on the MapleCloud, refer to the MapleCloud help page.
Download Help Document
What kind of issue would you like to report? (Optional)