Changeset 591 for library/doc/html/itfile.html
- Timestamp:
- 08/30/09 22:13:15 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
library/doc/html/itfile.html
r590 r591 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2 <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> 3 5 <title>mixpp: Writing and reading data from files</title> 4 <link href="tabs.css" rel="stylesheet" type="text/css"> 5 <link href="doxygen.css" rel="stylesheet" type="text/css"> 6 </head><body> 7 <!-- Generated by Doxygen 1.5.8 --> 6 <link href="tabs.css" rel="stylesheet" type="text/css"/> 7 <link href="doxygen.css" rel="stylesheet" type="text/css"/> 8 </head> 9 <body> 10 <!-- Generated by Doxygen 1.6.1 --> 8 11 <script type="text/javascript"> 9 12 <!-- … … 60 63 </div> 61 64 <div class="contents"> 62 <h1><a class="anchor" name="itfile">Writing and reading data from files </a></h1>Here we will use the <code>it_file</code> class to store some data. The program <code>write_it_file.cpp</code> looks as follows:<p> 65 66 67 <h1><a class="anchor" id="itfile">Writing and reading data from files </a></h1><p>Here we will use the <code>it_file</code> class to store some data. The program <code>write_it_file.cpp</code> looks as follows:</p> 63 68 <div class="fragment"><pre class="fragment"><span class="preprocessor">#include <itpp/itcomm.h></span> 64 69 … … 69 74 it_file ff; 70 75 71 <span class="comment">// Open a file with the name "it_file_test.it"</span>72 ff.open ( <span class="stringliteral"> "it_file_test.it"</span> );76 <span class="comment">// Open a file with the name "it_file_test.it"</span> 77 ff.open ( <span class="stringliteral">"it_file_test.it"</span> ); 73 78 74 79 <span class="comment">// Create some data to put into the file</span> 75 80 vec a = linspace ( 1, 20, 20 ); 76 81 77 <span class="comment">// Put the variable a into the file. The Name( "a") tells the file class</span>78 <span class="comment">// that the next variable shall be named "a".</span>79 ff << Name ( <span class="stringliteral"> "a"</span> ) << a;82 <span class="comment">// Put the variable a into the file. The Name("a") tells the file class</span> 83 <span class="comment">// that the next variable shall be named "a".</span> 84 ff << Name ( <span class="stringliteral">"a"</span> ) << a; 80 85 81 86 <span class="comment">// Force the file to be written to disc. This is useful when performing</span> … … 90 95 <span class="keywordflow">return</span> 0; 91 96 } 92 </pre></div><p> 93 When you run this program you will obtain a file called <code>it_file_test.it</code> in your current directory. You can read the file into Matlab/Octave to view the data by using the following commands:<p> 94 <div class="fragment"><pre class="fragment">itload(<span class="stringliteral">'it_file_test.it'</span>) 97 </pre></div><p>When you run this program you will obtain a file called <code>it_file_test.it</code> in your current directory. You can read the file into Matlab/Octave to view the data by using the following commands:</p> 98 <div class="fragment"><pre class="fragment">itload(<span class="stringliteral">'it_file_test.it'</span>) 95 99 figure(1); clf; 96 100 plot(a) 97 </pre></div><p> 98 Note: Make sure that <code>$PREFIX/share/itpp</code> is in your Matlab/Octave path and that you run the code above from the directory where <code>it_file_test.it</code> is located (<code>$PREFIX</code> is the IT++ installation prefix; <code>/usr/local</code> by default).<p> 99 The IT++ program <code>read_it_file.cpp</code> that reads the file and prints its content can look like this:<p> 100 <div class="fragment"><pre class="fragment"></pre></div><p> 101 Here is the output of the program:<p> 101 </pre></div><p>Note: Make sure that <code>$PREFIX/share/itpp</code> is in your Matlab/Octave path and that you run the code above from the directory where <code>it_file_test.it</code> is located (<code>$PREFIX</code> is the IT++ installation prefix; <code>/usr/local</code> by default).</p> 102 <p>The IT++ program <code>read_it_file.cpp</code> that reads the file and prints its content can look like this:</p> 103 <div class="fragment"><pre class="fragment"></pre></div><p>Here is the output of the program:</p> 102 104 <div class="fragment"><pre class="fragment"> 103 105 a = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20] 104 106 </pre></div> </div> 105 <hr size="1" ><address style="text-align: right;"><small>Generated on Sat Aug 29 20:49:422009 for mixpp by 107 <hr size="1"/><address style="text-align: right;"><small>Generated on Sun Aug 30 22:10:50 2009 for mixpp by 106 108 <a href="http://www.doxygen.org/index.html"> 107 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8</small></address>109 <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> 108 110 </body> 109 111 </html>