Trying to make a Hiragana guesser

3 次查看(过去 30 天)
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