User Tools

Site Tools


octave:octave

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
octave:octave [2008/08/06 15:45] devaoctave:octave [2008/08/06 15:54] deva
Line 6: Line 6:
   retval = param1 + param2;   retval = param1 + param2;
 end; end;
 +</code>
 +====strings====
 +<code matlab>
 +mystring = 'hello world';
 +sizeof(mystring)
 </code> </code>
  
 ====string array==== ====string array====
 <code matlab> <code matlab>
-myarray = { 'hello', 'world' };+myemptyarray = {}; % create empty string array. 
 + 
 +myarray = { 'hello', 'world' }; % create array with two strings. 
 +myarray(1) % prints 'hello' 
 +myarray(3) = 'blah'; %inserts another string into the array.
  
 +sizeof(myarray) % get number of elements
 +sizeof(myarray(1)) %get length of first string
 </code> </code>
 +Note: Arrays are 1-based, not 0-based as they usually are in real programming languages.
  
 ====if then else==== ====if then else====
octave/octave.txt · Last modified: 2009/04/23 13:54 by deva