[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How do I replace this "for" loop?
From: |
Keith Goodman |
Subject: |
Re: How do I replace this "for" loop? |
Date: |
Tue, 31 May 2005 14:19:46 -0700 |
On 5/31/05, Robert A. Macy <address@hidden> wrote:
> How do I replace these "for" loops?
>
> for i=1:rowsdata
> for k=1:columnsdata
> angleofdata(i,k)=angle(data(i,k));
> if (angleofdata(i,k)>3)
> angleofdata(i,k)=angleofdata(i,k)-2*pi();
> endif
> if (angleofdata(i,k)<-3)
> angleofdata(i,k)=angleofdata(i,k)+28pi();
> endif
> endfor
> endfor
Here's one way:
x = angle(data);
x(x > 3) = x(x>3) - 2*pi;
x(x < -3) = x(x < -3) + 2*pi;
Another:
x = angle(data);
x = x - (x > 3)*2*pi + (x < -3)*2*pi;
-------------------------------------------------------------
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
-------------------------------------------------------------