Connectivity - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Connectivity

 

Maple 18 includes new and expanded tools to connect to and work with external data sources and file formats. These include new support for connecting with Internet data sources, support for importing from and exporting to popular 3-D graphics formats, and working with compressed files.

 

Connecting to URL Data Sources

3-D Graphics Import/Export

Import and Export of Tabular and Spreadsheet Data

Compressed File Support

Export of Graphs to LaTeX

Connecting to URL Data Sources

The new URL package offers efficient tools for connecting to remote data sources using the HTTP, HTTP Secure (HTTPS), and FTP transfer protocols. For HTTP and Secure HTTP, both GET and POST operations are supported.

sitecontent  URL:-Get http://www.maplesoft.com :

lengthsitecontent

32144

(1.1)

As well, support for URLs has now been extended in many other places in Maple where filenames were previously supported, simplifying the steps necessary to connect to this data using Maple.

fingerprint  ImageTools:-Readhttp://www.maplesoft.com/data/examples/jpg/fingerprint.jpg

ImageTools:-Embedfingerprint

3-D Graphics Import/Export

The updated plottools package offers new tools and functionality for generating, importing, exporting 3-D graphic models in a variety of formats.

Importing and Exporting 3-D models

The new importplot and exportplot commands permit the exchange of 3-D geometric data between a variety of formats and Maple plots. After import, a geometric object can then be combined with other visualizations in Maple using existing tools such as plots[display].  The following new data formats are supported for both import and export:

 

BYU - Movie.BYU geometry

PLY - Stanford triangle format (ASCII & binary)

 

JVX - JavaView geometry

STL - Stereolithography file format (ASCII & binary)

 

OBJ - Wavefront file format

VTK - Visualization ToolKit file format

 

OFF - Object File Format

 

In addition to importing from a local file, importplot also allows the user to import directly from a URL.

Import Examples

The following examples illustrate imports from PLY and STL file formats.

gearcatkerneloptsdatadir,/example/gear.ply:

plottoolsimportplotgear

figurehttp://www.maplesoft.com/data/examples/stl/dodecahedron.stl:

plottoolsimportplotfigure

Export Examples

The following examples illustrate exporting Maple 3-D objects to BYU and OFF formats, then importing them back.

fy^3x^7*y^22*x^5:

knotalgcurvesplot_knotf,x,y,epsilon=0.8,radius=0.1,tubepoints=9,axes=none:

plots:-displayknot 

surface plot3d sinx+x*cosy, x=5..5, y=5..5,color=purple: 

plots:-displaysurface,axes=none

KnotFile cat FileTools:-TemporaryDirectory, /MyKnot.byu:

plottoolsexportplotKnotFile,knot:

SaddleFile cat FileTools:-TemporaryDirectory, /saddle.obj:

plottoolsexportplot SaddleFile,surface:

plottoolsimportplotKnotFile;

plottoolsimportplotSaddleFile

Import and Export of Tabular and Spreadsheet Data

The improved ImportMatrix and ExportMatrix commands enable tabular and spreadsheet data in a variety of formats to be imported to and exported from Maple matrices. The following new data formats are supported for both import and export:

 

DIF - Data Interchange Format

ODS - OpenDocument Spreadsheet

SXC - Sun XML Calc spreadsheet

These commands also now handle Excel spreadsheet files using the previously existing ExcelTools package. As a result, in total, they now support four additional formats. In addition to importing from a local file, ImportMatrix also supports importing data directly from a URL.

ImportMatrix examples

csvFile  catkerneloptsdatadir,/example/timedata.csv:

csvData  ImportMatrixcsvFile

MapleTimeline  http://www.maplesoft.com/data/examples/dif/maple-timeline.dif.gz:

timelineData  ImportMatrixMapleTimeline

Imported Excel Data

Imported DIF Data

Compressed File Support

Maple 18 supports both zip and gzip file formats.

The gzip format allows lossless compression of data in a single file. Your large matrix can be written to a file using this format, thus taking up less room on disk compared to an ordinary uncompressed data file.

The zip format allows lossless compression of organized collection of data and resources in a single file. Think of it as a collection of files zipped together in a single archive. By splitting the data into a directory structure within the zip file, the data is better organized for easy extraction.

To use the short form of command names, we'll load the package:

withFileTools:-Compressed:

Reading Zip Files

Now, let's point to a sample zip file and look to see what is included inside it:

zipfile  FileTools:-JoinPath kerneloptsmapledir, data, help, FileTools, sample.zip: 

Contentszipfile;

data.m,options.txt,antennas.jpg

(4.1.1)

There are three files, we will read each of them in.

The first file is stored with the suffix ".m", so it is immediately restored as a Maple object when read into Maple.

data  ReadFiledata.m in zipfile;

The second file is plain text. In this case we additionally use the parse command to turn the plain text into equations.

opts  parseReadFileoptions.txt in zipfile,string;

axes=none,view=600..300,800..100

(4.1.2)

The third file is an image. We will extract it into a temporary directory.

imagefile  catFileToolsTemporaryDirectory, /myantennas.jpg:

Extractantennas.jpg in zipfile, imagefile;

Now, let's plot the data, image, and options we just read in.

plotspolygonplot data, background=imagefile, opts;

Creating and Writing to Zip Files

This short section will show how the sample zip file was created.

Start with naming the container zip file -- "myzip.zip".  Individual files within the zip will be specified using in to separate the container name with the in-zip name. The data is already defined in the previous section, we'll write it out to a sub-file with a .m extension.

newzipfile  myzip.zip: 

WriteFile data.m in newzipfile, data ;

1633

(4.2.1)

Here the options are written as plain text.

WriteFile options.txt in newzipfile, axes=none, view=[-600..300,-800..100];

37

(4.2.2)

The image is taken from the data directory on disk and put directly into the zip archive.

ReadWriteFile antennas.jpg in newzipfile,  catkerneloptsmapledir,/data/images/antennas.jpg;

We are done. Let's look to see what is inside our new zip file.

Contentsnewzipfile;

data.m,options.txt,antennas.jpg

(4.2.3)

This new zip file that we created can be read by standard tools like WinZip and pkzip. Similarly, files created using these tools can be opened and read by Maple.

Export of Graphs to LaTeX

The new GraphTheory[Latex]  command generates LaTeX code for displaying a graph using the LaTeX picture environment. It handles directed and undirected graphs in both black and white and color. The vertex labels are placed beside the vertices in the LaTeX picture.

Example

withGraphTheory:

withSpecialGraphs:

We create an undirected unweighted soccer ball graph.

S:=SoccerBallGraph;

S:=Graph 2: an undirected unweighted graph with 60 vertices and 90 edge(s)

(5.1.1)

DrawGraphS;

Here we export the soccer ball graph S to a compilable LaTeX file.

LatexS,soccer.tex,300,300,true;

Finally, we compile "soccer.tex" and we obtain a LaTeX output document containing a picture as shown below:

 

 

See Also

Index of New Commands and Packages

What's New in GraphTheory