필터 지우기
필터 지우기

Trying to make a Hiragana guesser

조회 수: 3 (최근 30일)
Raul
Raul 2024년 2월 11일
댓글: VBBV 2024년 2월 11일
Hi, for one of my classes I've been trying to make a hiragana guesser, but when I run it nothing shows on the command window. I'm new to matlab so maybe I just made a mistake, but as far as I check I see nothing wrong. Does it have something to do with the symbols? When I run it here the symbol does appear, but the input does not work.
a=("あ");
i=("い");
u=("う");
e=("え");
o=("お");
rand=randi(5);
switch rand
case 1
disp(a)
hg=input("Insert Kana \n");
if hg==a
fprintf("Correct")
else
fprintf("Incorrect")
end
case 2
disp(i)
hg=input("Insert Kana \n");
if hg==i
fprintf("Correct")
else
fprintf("Incorrect")
end
case 3
disp(u)
hg=input("Insert Kana \n");
if hg==u
fprintf("Correct")
else
fprintf("Incorrect")
end
case 4
disp(e)
hg=input("Insert Kana \n");
if hg==e
fprintf("Correct")
else
fprintf("Incorrect")
end
case 5
disp(o)
hg=input("Insert Kana \n");
if hg==o
fprintf("Correct")
else
fprintf("Incorrect")
end
end
Unable to run the 'fevalJSON' function because it calls the 'input' function, which is not supported for this product offering.
  댓글 수: 1
VBBV
VBBV 2024년 2월 11일
a=("あ");
i=("い");
u=("う");
e=("え");
o=("お");
rand=randi(5)
rand = 2
switch string(rand)
case '1'
disp(a)
hg="a"%input("Insert Kana \n");
if strcmp(hg,a)
fprintf("Correct")
else
fprintf("Incorrect")
end
case '2'
disp(i)
hg= "い"%input("Insert Kana \n");
if strcmp(hg,i)
fprintf("Correct")
else
fprintf("Incorrect")
end
case '3'
disp(u)
hg="あ"%input("Insert Kana \n");
if strcmp(hg,u)
fprintf("Correct")
else
fprintf("Incorrect")
end
case '4'
disp(e)
hg="y"%input("Insert Kana \n");
if strcmp(hg,e)
fprintf("Correct")
else
fprintf("Incorrect")
end
case '5'
disp(o)
hg="t"%input("Insert Kana \n");
if strcmp(hg,o)
fprintf("Correct")
else
fprintf("Incorrect")
end
end
hg = "い"
Correct
The input function cannot work in online editor, but certainly it does when its run in a PC installed with MATLAB

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

채택된 답변

VBBV
VBBV 2024년 2월 11일
rand=randi(5)
rand = 2
switch string(rand)
case '1'
disp('something')
case '2'
disp('something')
end
something
  댓글 수: 4
Raul
Raul 2024년 2월 11일
Thank you it worked and now I can expand it to the rest of the hiragana alphabet.
VBBV
VBBV 2024년 2월 11일
Yes. It's shown in my comment to your question. If it worked for you please accept the answer. Thank you

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by