help-octave
[Top][All Lists]
Advanced

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

Simple 'for' loop question


From: Rob Teasdale
Subject: Simple 'for' loop question
Date: Tue, 5 Jun 2007 14:57:52 -0700 (PDT)

Hi all,

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. Other loops I have constructed the same way work fine, but as I have 
been at it all day maybe I cant see the forest for the trees here.  Any help 
would be greatly appreciated,

Cheers
Rob

function [CO] = p_area(X,Y,Z,O)
    [R C] = size(X)
    row = 1;
    for i = 1:R
        for j = 1:C
            C = [X(i,j) Y(i,j) Z(i,j)];
            CO(row,:) = O - C;
            row = row + 1;                    % will count one extra but out of 
loop by then
            printf("%d,%d\n",i,j)
        end
    end


Output
octave:3> rob_test
R =  3
C =  4
1,1
1,2
1,3
1,4
octave:4>






      
_________________________________________________________________________________
              

How would you spend $50,000 to create a more sustainable environment in 
Australia? Go to Yahoo!7 Answers and share your idea.
http://advision.webevents.yahoo.com/aunz/lifestyle/answers/y7ans-babp_reg.html





reply via email to

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