help-octave
[Top][All Lists]
Advanced

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

Re: Possible bug? cell array indexing problem


From: Carnë Draug
Subject: Re: Possible bug? cell array indexing problem
Date: Tue, 18 Dec 2012 16:15:26 +0000

Moved from maintainers to help mailing list...

On 17 December 2012 18:52, mass168 <address@hidden> wrote:
> Thanks for the reply. Apologies, I tried to simplify this block of code, and
> accidentally left out some critical lines. It should have read as follows:
>
> y={[1,2,3];[5,8,9];[35:2:46]}
>
> n1=3; %Left out
> n2=2; %Left out
> n3=3; %Left out
>
>  for n103=1:3
>  a=num2str(n103)
>  b=strcat('n',a)
> y{b,1}(1,3)
>  endfor
>
> However, with this said, I'm tracking on your explanation that strings
> cannot be indexes. My question remains, is there a way to accomplish the
> intent of what i was doing here? I need the index "b" to be created
> externally, and it must be of the form that I used here (i.e n1, n2), or the
> more complicated example will not work.   Thanks!
>
> MJ

ok, so your problem is that `b' is not the variable for the index, but
the name of the variable that holds the index. Use eval(). Still, my
advice would be to redesign the thing, it looks messy.

Carnë


reply via email to

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