Writing a script that tells you the quadrant of the coordinates

조회 수: 14 (최근 30일)
Seth
Seth 2014년 10월 26일
답변: Rashmil Dahanayake 2014년 10월 26일
I am not sure how to go about this question. Any help will be greatly appreciated. Write a function quadrant that receives two arguments, which are a pair of (X, Y) coordinates, and returns the corresponding quadrant in roman numerals (i.e. I-IV), for example,>> fprintf('Input coordinates will be in quadrant %s.\n',quadrant(3,4)) Input coordinates will be in quadrant I.
  댓글 수: 1
Roger Stafford
Roger Stafford 2014년 10월 26일
Hint: See if you can convert the logicals x>=0 and y>=0 into numbers from one to four in accordance with the quadrant. Is really is easy to do.

댓글을 달려면 로그인하십시오.

채택된 답변

Rashmil Dahanayake
Rashmil Dahanayake 2014년 10월 26일
x=4;y=-7; %test value
switch true
case x >=0 && y>0
disp('Quadrant I')
case x <=0 && y>0
disp('Quadrant II')
case x <=0 && y<0
disp('Quadrant III')
case x >=0 && y<0
disp('Quadrant IV')
otherwise
disp('Origin')
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 NaNs에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by