Converting String to Character,

조회 수: 5 (최근 30일)
Sean St Cyr
Sean St Cyr 2020년 7월 7일
댓글: dpb 2020년 7월 7일
Hi, I got an error saying that my code below for the Hit, Miss, Total Miss, and Bullseye is currently a string and needs to be "of data type char" and I was wondering if someone could help
function[zone,Points]=RQ18_18(X,Y)
distance=sqrt(X^2 + Y^2);
Bluedistance=3;
Greendistance=2;
Reddistance=1;
if( distance<=Reddistance)
Points=4;
zone="Bullseye";
elseif(distance>Reddistance && distance<=Greendistance)
Points=2;
zone="Close";
elseif(distance>Greendistance &&distance<=Bluedistance)
Points=1;
zone="Hit";
elseif((X>=4 && X<=-4) && (Y>=-4 && Y<=-4))
Points=0;
zone="Miss";
else
Points=-1;
zone="Total Miss";
end
end
  댓글 수: 3
Sean St Cyr
Sean St Cyr 2020년 7월 7일
Thank you, I got it fixed
dpb
dpb 2020년 7월 7일
Just a stylistic comment -- it helps ALOT to indent code constructs in being able to read and debug code...sure, the machine doesn't care, but it doesn't do the hard work of writing the code.

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

답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by