help-octave
[Top][All Lists]
Advanced

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

Cellfun Index


From: Mike Bloom
Subject: Cellfun Index
Date: Wed, 29 Nov 2017 09:03:05 -0600

Hi, I'm using cellfun to use one cell which contains indexes to index from another cell.  My code is like this:

cellData = cell(1,2);
cellIndex = cell(1,2);

cellData{1} = [10:-1:1];
cellData{2} = [5:-1:1];

cellIndex{1} = [2,4,5];
cellIndex{2} = [2];

cellResult = cellfun(@(a,b) a(b), cellData, cellIndex, "UniformOutput", false)

And the result is this:

cellResult =
{
  [1,1] =

     9   7   6

  [1,2] =  4
}

This is the correct result.  My question is, is there a function available so that I can use cellfun without the anonymous function call?  I've tried looking through the function index, but wasn't able to find anything.  I want to avoid the anonymous function in order to try to speed the code up.

Thanks

reply via email to

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