Effacer les filtres
Effacer les filtres

Trying to make a Hiragana guesser

3 vues (au cours des 30 derniers jours)
Raul
Raul le 11 Fév 2024
Commenté : VBBV le 11 Fév 2024
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 commentaire
VBBV
VBBV le 11 Fév 2024
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

Connectez-vous pour commenter.

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Functions dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by