[Top][All Lists]

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

Re: error: only one index allowed for lists

From: Quentin Spencer
Subject: Re: error: only one index allowed for lists
Date: Mon, 03 Oct 2005 12:50:59 -0500
User-agent: Mozilla Thunderbird 1.0.7-1.1.fc4 (X11/20050929)

Prasenjit Kapat wrote:

The subject gives the error message. A toyed down version of what I
want to do is this..

a = cell(1,3);
a{1} = zeros(2,3);
a{2} = ones(2,3);
a{3} = zeros(2,3);
a{:}(1,1)  ## I want this to give [ 0 1 0] as the answer, instead the error...
error: only one index allowed for lists

I get what this means. Is there any way around ? To be more fair to my
problem, I want a 2x3 matrix b = some_function(a) such that, b(i,j) =
a{1}(i,j) + a{2}(i,j) + a{3}(i,j). Of course, in real terms these
dimensions are huge, so is the 'length of the list'. Thus the brute
force way is expensive,O(n^3). Some N-dimensional array, like matlab ?
Well, I do not have administrative access to the machine, and the
octave version is an age old one: 2.1.50, possibly on fedora 1.

This type of operation isn't allowed because it really can't be defined in any sensible way for cell arrays. The contents of each cell are allowed to have different types (string, double, cell, struct, etc), and different dimensions. An operation such as the one you suggest would make sense for your example, where each element is a matrix of identical size, but not for a general cell array. I think your problem definitely calls for N-D arrays, which were introduced to Octave shortly after 2.1.50 if I recall correctly. If you don't have admin access, you might try compiling your own copy of octave in your home directory. I've been able to make this work successfully before. It does require a lot of disk space, though, so that could be problematic if you have quotas--maybe you could compile in /tmp.


Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:
How to fund new projects:
Subscription information:

reply via email to

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