LearningGuide

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: ommand to select the first and the third entries in each column. > convert( L[[1..-1],[1,3]], listlist ); [[0, 0], [1, 0.8414709848], [2, 0.9092974268], [3, 0.1411200081], [4, −0.7568024953], [5, −0.9589242747], [6, −0.2794154982]] The plot command can plot lists directly. > plot(%); 0.8 0.6 0.4 0.2 0 –0.2 –0.4 –0.6 –0.8 1 2 3 4 5 6 To select the second column of numbers, you can use the fact that L[5,2] is the second number in the fifth sublist. > L[5,2]; −0.6536436209 You need the following data. > L[ 1..-1, 2 ]; 1 0.5403023059 −0.4161468365 −0.9899924966 −0.6536436209 0.2836621855 0.9601702867 Convert this data to a list, and then find the mean. 280 • Chapter 8: Input and Output > convert(L[1..-1,2],list); [1, 0.5403023059, −0.4161468365, −0.9899924966, −0.6536436209, 0.2836621855, 0.9601702867] > stats[describe,mean](%) ; 0.1034788321 You can also perform calculations on your matrix L using the LinearAlgebra package. > LinearAlgebra[Transpose](L) . L; [91. , 1.30278930720000119 , −6.41489848119999984] [1.30278930720000119 , 3.87483111270157598 , −0.109078174475632172] [−6.41489848119999984 , −0.109078174475632172 , 3.12516888746710864] For more information regarding options for use with ImportMatrix, refer to the ?ImportMatrix help page. Reading Commands from a File Some Maple users find it convenient to write Maple programs in a text file with a text editor, and then import the file into Maple. You can paste the commands from the text file into your worksheet 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 worksheet but it does not, by default, place the commands from the file in your worksheet. Use the read command with the following syntax. read "filename "; For example, the file ks.tst contains the following Maple commands. S := n -> sum( binomial(n, beta) * ( (2*beta)!/2^beta - beta!*beta ), beta=1..n ); S( 19 ); 8.2 Writing Data to a File • 281 When you read the file, Maple displays the results but not the commands. > read "ks.tst"; n S := n → β =1 binomial(n, β ) ( (2 β )! − β! β) 2β 1024937361666644598071114328769317982974 Inserting Commands If you set the interface variable echo to 2, Maple inserts the commands from the file into your worksheet. > interface( echo=2 ); > read "ks.tst"; > S := n -> sum( binomial(n, beta) > * ( (2*beta)!/2^beta - beta!*beta ), beta=1..n ); n S := n → β =1 binomial(n, β ) ( (2 β )! − β! β) 2β > S( 19 ); 1024937361666644598071114328769317982974 The read command can also read files in Maple internal format. See 8.2 Writing Data to a File. 8.2 Writing Data to a File After using Maple to perform a calculation, you may want to save the result in a file. You can then process the result later, either with Maple or with another prog...
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