help-octave
[Top][All Lists]
Advanced

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

Re: Simple 'for' loop question


From: Jordi Gutierrez Hermoso
Subject: Re: Simple 'for' loop question
Date: Tue, 5 Jun 2007 17:54:53 -0500

On 05/06/07, Rob Teasdale <address@hidden> wrote:
I am stumped as to why this system of loops does not iterate
properly. It only runs the first loop once (even thought there are
three rows in the matrix) and the exits.

You have a name clash in

 C = [X(i,j) Y(i,j) Z(i,j)];
 CO(row,:) = O - C;

these two lines. Rename the second C to something else.

Incidentally, this is how you can avoid for loops altogether in this example:

    CO = [X'(:),Y'(:),Z'(:)] - repmat(O,sum(size(X)),1);

HTH,
- Jordi G. H.


reply via email to

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