help-octave
[Top][All Lists]
Advanced

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

Re: How doyou vectorize pulling values out of a matrix?


From: Jordi Gutierrez Hermoso
Subject: Re: How doyou vectorize pulling values out of a matrix?
Date: Mon, 24 Jul 2006 18:09:54 -0500

On 24/07/06, Robert A. Macy <address@hidden> wrote:

this for loop works...
>> for i=1:100
>> output(i)=mymatrix(Xindex(i),Yindex(i));
>> endfor

but this didn't...
>> output(1,:)=mymatrix(Xindex(1,:),Yindex(1,:));
everything matches, what's wrong?

how do you vectorize this operation?

I'm not sure this is the best way, but at least it works and it's vectorised:

    octave:1> output = diag(mymatrix(Xindex,Yindex));

HTH,
- Jordi G. H.


reply via email to

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