[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: subarray(x, d, k) for picking all k-th elements of d-th dimension o
From: |
Jaroslav Hajek |
Subject: |
Re: subarray(x, d, k) for picking all k-th elements of d-th dimension of x ? |
Date: |
Fri, 24 Apr 2009 13:13:52 +0200 |
On Fri, Apr 24, 2009 at 1:10 PM, Jaroslav Hajek <address@hidden> wrote:
> On Fri, Apr 24, 2009 at 12:37 PM, G.. <address@hidden> wrote:
>>
>>
>> Jaroslav Hajek-2 wrote:
>>>
>>> Well, no, but you can write it:
>>>
>>> idx = {':'}(ones (1, max (ndims (x), d))); idx{d} = k; % or anything
>>> y = x(idx{:});
>>>
>>
>> Great! I think I got a glimpse about indexing now. I never found it
>> documented.
>>
>> G.
>>
>
> I think it actually is documented - maybe you weren't aware that you
> can use a cs-list as index, but this more or less follows from the
> docs, I think. Another trick is maybe that you can use the ':' string
> instead of : - I think that's documented too, though I'm not sure. The
> rest is just thinking...
> In any case, feel free to improve the docs, clarify anything, provide
> any examples you find useful. I think there's nobody there thinking
> that Octave's documentation is too detailed.
>
Also, I would agree with contributing such a function (agreed the
trick is not really obvious), say, to the general package on
OctaveForge, if you feel like it.
But in that case, I'd ask you to invent a somewhat more descriptive
name, subarray is just too general. No ideas myself, though.
cheers
--
RNDr. Jaroslav Hajek
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz
- subarray(x, d, k) for picking all k-th elements of d-th dimension of x ?, G.., 2009/04/24
- Re: subarray(x, d, k) for picking all k-th elements of d-th dimension of x ?, Jaroslav Hajek, 2009/04/24
- Re: subarray(x, d, k) for picking all k-th elements of d-th dimension of x ?, G.., 2009/04/24
- Re: subarray(x, d, k) for picking all k-th elements of d-th dimension of x ?, Jaroslav Hajek, 2009/04/24
- Re: subarray(x, d, k) for picking all k-th elements of d-th dimension of x ?,
Jaroslav Hajek <=
- Re: subarray(x, d, k) for picking all k-th elements of d-th dimension of x ?, G.., 2009/04/24
- Re: subarray(x, d, k) for picking all k-th elements of d-th dimension of x ?, Jaroslav Hajek, 2009/04/24
- Re: subarray(x, d, k) for picking all k-th elements of d-th dimension of x ?, Francesco Potorti`, 2009/04/24