int1x41x int1x41x 1 x2 x 2 1 1 1

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: a Taylor approximation; and manipulate and solve ordinary and partial differential equations, numerically as well as symbolically. 8 Input and Output Maple provides convenient ways to import and export raw numerical data and graphics. It presents individual algebraic and numeric results in formats suitable for use in FORTRAN, C, or the mathematical typesetting A system L TEX. You can export the entire worksheet as a file in any of the A following formats: HTML or HTML with MathML, L TEX, Maple Input, Maple Text, Maplet application, Plain Text, or Rich Text Format. You can cut and paste results, and export either single expressions or entire worksheets. This chapter discusses the most common aspects of exporting and importing information to and from files. It introduces how Maple interacts with the file system on your computer, and how Maple can begin interacting with other software. In This Chapter • Reading Files • Writing Data to a File • Exporting Worksheets • Printing Graphics 8.1 Reading Files The two most common cases for reading files are to obtain data and to retrieve Maple commands stored in a text file. • The first case is often concerned with data generated from an experiment. You can store numbers separated by whitespace and line breaks in a text file, then read them into Maple for study. You can 277 278 • Chapter 8: Input and Output accomplish these operations by using the Maple ExportMatrix and ImportMatrix commands. • The second case concerns reading commands from a text file. Perhaps you have received a worksheet in text format, or you have written a Maple procedure by using a text editor and have stored it in a text file. You can cut and paste commands into Maple or you can use the read command. The following section discusses the second case. Reading Columns of Numbers from a File If you generate data outside Maple, you must read it into Maple before you can manipulate it. Often such external data is in the form of columns of numbers in a text file. The file data.txt below is an example. 0 1 2 3 4 5 6 10 .5403023059 .8414709848 -.4161468365 .9092974268 -.9899924966 .1411200081 -.6536436209 -.7568024953 .2836621855 -.9589242747 .9601702867 -.2794154982 The ImportMatrix command reads columns of numbers. Use ImportMatrix as follows. ImportMatrix( "filename ", delimiter=string ) • filename is the name of the file to read • string is the character that separates the entries in the file. The default value of string is a tab, represented by using "\t". In data.txt, the entries are separated by spaces, so the value of string is " " > L := ImportMatrix( "data.txt", delimiter="\t" ); 0 1 2 L := 3 4 5 6 1 0.5403023059 −0.4161468365 −0.9899924966 −0.6536436209 0.2836621855 0.9601702867 0 0.8414709848 0.9092974268 0.1411200081 −0.7568024953 −0.9589242747 −0.2794154982 8.1 Reading Files • 279 For example, you can plot the third column against the first. Use the convert c...
View Full Document

This note was uploaded on 08/27/2012 for the course MATH 1100 taught by Professor Nil during the Spring '12 term at National University of Singapore.

Ask a homework question - tutors are online