Changeset 651 for library/doc/html/itfile.html
- Timestamp:
- 10/12/09 13:49:39 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
library/doc/html/itfile.html
r641 r651 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"/> 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"> 5 3 <title>mixpp: Writing and reading data from files</title> 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 --> 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.9 --> 11 8 <script type="text/javascript"> 12 9 <!-- … … 63 60 </div> 64 61 <div class="contents"> 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> 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> 68 63 <div class="fragment"><pre class="fragment"><span class="preprocessor">#include <itpp/itcomm.h></span> 69 64 … … 74 69 it_file ff; 75 70 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> );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> ); 78 73 79 74 <span class="comment">// Create some data to put into the file</span> 80 75 vec a = linspace ( 1, 20, 20 ); 81 76 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;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; 85 80 86 81 <span class="comment">// Force the file to be written to disc. This is useful when performing</span> … … 95 90 <span class="keywordflow">return</span> 0; 96 91 } 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>) 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>) 99 95 figure(1); clf; 100 96 plot(a) 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> 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> 104 102 <div class="fragment"><pre class="fragment"> 105 103 a = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20] 106 104 </pre></div> </div> 107 <hr size="1" /><address style="text-align: right;"><small>Generated on Sun Sep 27 00:49:052009 for mixpp by 105 <hr size="1"><address style="text-align: right;"><small>Generated on Wed Oct 7 17:34:44 2009 for mixpp by 108 106 <a href="http://www.doxygen.org/index.html"> 109 <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1</small></address>107 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address> 110 108 </body> 111 109 </html>