Show
Ignore:
Timestamp:
08/30/09 22:13:15 (15 years ago)
Author:
smidl
Message:

doc

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"/> 
    35<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 --> 
    811<script type="text/javascript"> 
    912<!-- 
     
    6063</div> 
    6164<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> 
    6368<div class="fragment"><pre class="fragment"><span class="preprocessor">#include &lt;itpp/itcomm.h&gt;</span> 
    6469 
     
    6974        it_file ff; 
    7075 
    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 &quot;it_file_test.it&quot;</span> 
     77        ff.open ( <span class="stringliteral">&quot;it_file_test.it&quot;</span> ); 
    7378 
    7479        <span class="comment">// Create some data to put into the file</span> 
    7580        vec a = linspace ( 1, 20, 20 ); 
    7681 
    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 &lt;&lt; Name ( <span class="stringliteral">"a"</span> ) &lt;&lt; a; 
     82        <span class="comment">// Put the variable a into the file. The Name(&quot;a&quot;) tells the file class</span> 
     83        <span class="comment">// that the next variable shall be named &quot;a&quot;.</span> 
     84        ff &lt;&lt; Name ( <span class="stringliteral">&quot;a&quot;</span> ) &lt;&lt; a; 
    8085 
    8186        <span class="comment">// Force the file to be written to disc. This is useful when performing</span> 
     
    9095        <span class="keywordflow">return</span> 0; 
    9196} 
    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">&apos;it_file_test.it&apos;</span>) 
    9599figure(1); clf; 
    96100plot(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> 
    102104<div class="fragment"><pre class="fragment"> 
    103105a = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20] 
    104106</pre></div> </div> 
    105 <hr size="1"><address style="text-align: right;"><small>Generated on Sat Aug 29 20:49:42 2009 for mixpp by&nbsp; 
     107<hr size="1"/><address style="text-align: right;"><small>Generated on Sun Aug 30 22:10:50 2009 for mixpp by&nbsp; 
    106108<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> 
    108110</body> 
    109111</html>