help-octave
[Top][All Lists]
Advanced

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

Unidentified subject!


From: Antonio L.
Subject: Unidentified subject!
Date: Sat, 27 Mar 2004 07:58:25 -0600
User-agent: Internet Messaging Program (IMP) 3.2.1

Hello, mi problem can be split into two separated topics:
- Is there a more efficient way of doing this? (that is, without 'for' looping):

        for i=1:n
                M(I(n,1),J(n,1)) = V(n,1);
                endfor;

Where V,I,J are nx1 vectors, and M is a nxm matrix? Suposing indexing M with
values contained in vectors I and J is always possible.
It should be obvious that the best way for doing so would simply be

        M(I,J) = V;

but octave doesn't works like that.

- Supposing we can do that, what about dealing with the case where [I,J] values
could index cells outside the given matrix? Just like the code below:

        for i=1:n
                for j=1:m
                        if ( (0<i<=rows(M)) && (0<j<=columns(M)) )
                                M(i,j) = M2(I(i,j),J(i,j));
                        else
                                M(i,j) = value;
                        endfor;
                endfor

Where M, I, J are nxm matrices, and M2 is a general matrix. Is there an
efficient and elegant solution, preferredly avoiding 'for' loops?

            Thank you, Antonio.




-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/



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

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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