help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: writing functions that accept arrays/(matrcies?)


From: Jaroslav Hajek
Subject: Re: writing functions that accept arrays/(matrcies?)
Date: Mon, 9 Nov 2009 07:36:45 +0100

On Mon, Nov 9, 2009 at 1:37 AM, Christopher Harvey
<address@hidden> wrote:
> Hello list,
> I'm pretty new to octave and I have a few questions.
>
> I'll try to keep them in list form as much as possible.
>
> Are ranges, arrays and matrices the same thing in octave? (ie the same data
> type?)
>

No. Ranges are kept in a packed form until you modify them.

> 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?
> How do other built in functions handle this in octave?

A matrix is also an array - Octave's arrays are n-dimensional. If you
only want vectors (1d arrays), check that the dimensions are 1xn or
nx1 (or whatever you want to allow).

>
> 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]
>

You can find examples in the manual or at the Octave wiki.

-- 
RNDr. Jaroslav Hajek
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz


reply via email to

[Prev in Thread] Current Thread [Next in Thread]