Difference between revisions of "Matlab/MatlabIntro"

From mn/geo/geoit
Jump to: navigation, search
(Created page with "<rst> * Squared brackets concatenate strings: This works also for other matrices To add a path and a filename, for instance, use :: a = ['pathto/' 'myfile']; ...")
 
Line 1: Line 1:
<rst>
+
*Squared brackets concatenate strings:
* Squared brackets concatenate strings:
 
  
 
   This works also for other matrices
 
   This works also for other matrices
  
 
   To add a path and a filename, for instance, use
 
   To add a path and a filename, for instance, use
 
+
  ::
+
&nbsp;::
 
+
    a = ['pathto/' 'myfile'];
+
  a = ['pathto/' 'myfile'];
  
  
* Use *textread* to read in ASCII files
+
 
 
+
*Use *textread* to read in ASCII files
 +
 
 
   *'headerlines'* skips lines in the beginning
 
   *'headerlines'* skips lines in the beginning
 
+
  The format string tells which kind of variable to read.
+
The format string tells which kind of variable to read.
 
+
  ::
+
&nbsp;::
 
+
  [a b c] = textread( file, '%5n %3f', 'headerlines', 2);
+
[a b c] = textread( file, '%5n&nbsp;%3f', 'headerlines', 2);
  
 
   An empty format string reads the whole file
 
   An empty format string reads the whole file
  
  ::
+
&nbsp;::
 
+
  [a] = textread( file, '', 'headerlines', 2);
+
[a] = textread( file, '', 'headerlines', 2);''
 
 
 
 
 
 
</rst>
 

Revision as of 11:51, 5 January 2015

  • Squared brackets concatenate strings:
 This works also for other matrices
 To add a path and a filename, for instance, use

 ::

  a = ['pathto/' 'myfile'];


  • Use *textread* to read in ASCII files
 *'headerlines'* skips lines in the beginning

The format string tells which kind of variable to read.

 ::

[a b c] = textread( file, '%5n %3f', 'headerlines', 2);
 An empty format string reads the whole file
 ::

[a] = textread( file, , 'headerlines', 2);