help-octave
[Top][All Lists]
Advanced

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

Re: operation with array .


From: Carlo De Falco
Subject: Re: operation with array .
Date: Thu, 24 Jan 2019 14:19:32 +0000


> On 24 Jan 2019, at 13:59, gigiolone123 <address@hidden> wrote:
> 
> r =
> 
>   1   4   2   5  6 3     
> 
>>> col=[1 2 3 4 5 6] 
> col=
> 
>  1   2   3   4   5   6
> 
> 
> i want to find element in ff by: x(as rows) and col(as colums)
> 
> i want this:
> 
>       1,1 ===>53
> 
>       4,2 ===>5
> 
>       2,3 ====>38
> 
>       5,4 ===>42
> 
>       6,5 ===>13
> 
>      3,6 ===>23
> 
> 
> ans=53 5 38 42 13 23     



I guess what you want is sub2ind : 

ff = [ 53   28    6    6   68   78
       97   74   38   37   91   32
       18   38   18    9   82   23
       90    5   25   30   44   20
       18   87   28   42   60   64
       99   19   42   83   13   18];

r=[1 4 2 5 6 3];
col=[1 2 3 4 5 6];

ff(sub2ind ([6, 6], r, col))

ans =

   53    5   38   42   13   23

c.






reply via email to

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