[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: writing functions that accept arrays/(matrcies?)
From: |
Jordi Gutiérrez Hermoso |
Subject: |
Re: writing functions that accept arrays/(matrcies?) |
Date: |
Sun, 8 Nov 2009 22:44:34 -0600 |
2009/11/8 Christopher Harvey <address@hidden>:
> Are ranges, arrays and matrices the same thing in octave? (ie the same data
> type?)
Internally, no. For you, yes, they are; you shouldn't normally care
about whatever Octave does to choose the best internal representation
of each.
> If I write a function that accepts arrays (ranges?) like sin([1:10]) how can I
> check to make sure that it's not a matrix that's actually passed in?
Octave in general has pretty weak type checking , but there are
various isfoo functions you can use to check for type foo.
> I would like to write a function that can accept and produce arrays, can I get
> a template that can do this? ie: myFunction([1:10], 1, 2, 3)
> that returns [x1, x2, x3....... x10]
Just return matrices from your functions. Octave also supports
returning simultaneous multiple return values from a function.