octave:octave
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
octave:octave [2008/08/06 15:54] – deva | octave:octave [2008/08/06 16:25] – deva | ||
---|---|---|---|
Line 7: | Line 7: | ||
end; | end; | ||
</ | </ | ||
+ | |||
====strings==== | ====strings==== | ||
<code matlab> | <code matlab> | ||
- | mystring = 'hello world'; | + | mystring = 'hello world'; |
- | sizeof(mystring) | + | sizeof(mystring) |
+ | |||
+ | mystrilyng2 = [ mystring, ' | ||
</ | </ | ||
+ | sizeof on works in octave. in matlab the length of a string cannot be obtained! | ||
====string array==== | ====string array==== | ||
Line 23: | Line 28: | ||
sizeof(myarray) % get number of elements | sizeof(myarray) % get number of elements | ||
sizeof(myarray(1)) %get length of first string | sizeof(myarray(1)) %get length of first string | ||
+ | |||
+ | % Iterate strings in string array | ||
+ | for str = myarray | ||
+ | disp(str) | ||
+ | end | ||
+ | |||
</ | </ | ||
Note: Arrays are 1-based, not 0-based as they usually are in real programming languages. | Note: Arrays are 1-based, not 0-based as they usually are in real programming languages. | ||
+ | Note: sizeof is an octave-only function. size can be used to get the array size in matlab. | ||
====if then else==== | ====if then else==== |
octave/octave.txt · Last modified: 2009/04/23 13:54 by deva