Filter löschen
Filter löschen

Trying to make a Hiragana guesser

3 Ansichten (letzte 30 Tage)
Raul
Raul am 11 Feb. 2024
Kommentiert: VBBV am 11 Feb. 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 Kommentar
VBBV
VBBV am 11 Feb. 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

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Functions finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by