93

edits

Jump to navigation
Jump to search

m

formatting

(+ more tips) |
m (formatting) |
||

Line 128: | Line 128: | ||

These same tricks are useful for reading and writing data files with unique names, etc. | These same tricks are useful for reading and writing data files with unique names, etc. | ||

==Vectorizing Tricks | ==Vectorizing Tricks== | ||

You can easily fill a vector with an index: | You can easily fill a vector with an index: | ||

Line 134: | Line 134: | ||

x = [1:n]; | x = [1:n]; | ||

This works for expressions on the index by wrapping the index in an expression: | This works for expressions on the index by wrapping the index in an expression: | ||

for i=1:n, x(i) = sin(2*pi*i*f/r); end | for i=1:n, x(i) = sin(2*pi*i*f/r); end | ||

x = sin(2*pi*[1:n]*f/r); | x = sin(2*pi*[1:n]*f/r); | ||

Retrieved from "https://wiki.octave.org/Special:MobileDiff/152"