Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
can't idenfity loop pattern

Subject: can't idenfity loop pattern

From: Natalie Sin Hwee

Date: 20 Aug, 2010 10:38:03

Message: 1 of 1

Dear Mathworks,

I'm trying to create a loop with the criteria below:

Theta= 100x100 matrix with values ranging from 0 to 2pi.

s=8; %number of connectivity
sectAngle=(2*pi)/s;

sect1=(0<phi) & (phi<(pi/4)) & (0<theta) & (theta<(pi/4)) ;
sect2= ((pi/4)<phi) & (phi<(pi/2)) & ((pi/4)<theta) & (theta<(pi/2)) ;
sect3= ((pi/2)<phi) & (phi<(3*pi/4)) & ((pi/2)<theta) & (theta<(3*pi/4)) ;
sect4=((3*pi/4)<phi) & (phi<pi) & ((3*pi/4)<theta) & (theta<pi) ;

sect5=((3*pi/4)<phi) & (phi<pi) & (pi<theta) & (theta<(5*pi/4)) ;
sect6= ((pi/2)<phi) & (phi<(3*pi/4)) & ((5*pi/4)<theta) & (theta<(3*pi/2)) ;
sect7= ((pi/4)<phi) & (phi<(pi/2)) & ((3*pi/2)<theta) & (theta<(7*pi/4)) ;
sect8=(0<phi) & (phi<(pi/4)) & ((7*pi/4)<theta) & (theta<(2*pi)) ;

I can only manage to write the loop for theta:

for dd = 1:s;
    sect(:,:,dd) = (sectAngle*(dd-1))<theta & theta<(sectAngle*dd);
    sect_dist(:,:,dd)=sect(:,:,dd).*dist;
end


any ideas how i can write a loop for both phi and theta?

Thank you
Natalie

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us