フィルターのクリア

if elseif function not working properly

1 回表示 (過去 30 日間)
David Phung
David Phung 2014 年 10 月 26 日
コメント済み: David Phung 2014 年 10 月 26 日
Hey, this is my code and it doesnt work if I try to get something in the 3rd or 4th quadrant. Can someone tell me where my mistake is?
function [ romannum ] = quadrant( x,y )
if x>0, y>0
fprintf('Input coordinates will be in quadrant I. \n')
elseif x<0,y>0
fprintf('Input coordinates will be in quadrant II. \n')
elseif x<0,y<0
fprintf('Input coordinates will be in quadrant III. \n')
elseif x>0, y<0
fprintf('Input coordinates will be in quadrant IV. \n')
end
end

採用された回答

the cyclist
the cyclist 2014 年 10 月 26 日
This syntax
if x>0, y>0
is wrong. It should be
if x>0 & y>0
assuming you mean "and".
  1 件のコメント
David Phung
David Phung 2014 年 10 月 26 日
Thank you so much! I cant believe I overlooked that.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by