help me with a simple program

조회 수: 1 (최근 30일)
Tarek Alnajjar
Tarek Alnajjar 2015년 4월 6일
답변: Tarek Alnajjar 2015년 4월 6일
I don't know much about matlab so Im hoping for some help from u guys
I must create 1 dice that has 4 faces and roll it the results should be :
1=right
2=left
3=up
4=down
totally random and must be done 50 times plz reply :)
  댓글 수: 1
Jan
Jan 2015년 4월 6일
Please post more details. What exactly does "create" mean here? A 3D visualization? A function which replies random numbers?

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

채택된 답변

Mahdiyar
Mahdiyar 2015년 4월 6일
rolls = randi(4, 1, 50)
for i=1:50
switch rolls(i)
case 1
Results(i) = {'right'};
case 2
Results(i) = {'left'};
case 3
Results(i) = {'up'};
case 4
Results(i) = {'down'};
end
end

추가 답변 (3개)

Image Analyst
Image Analyst 2015년 4월 6일
Use randi():
rolls = randi(4, 1, 50)
  댓글 수: 2
Tarek Alnajjar
Tarek Alnajjar 2015년 4월 6일
I donno how to explain my question perfectly but what I need is when I get the result for the random number for exaple:(if the answer was 4 it should wright down or arrow down) or 1= -> 2= <- 3= Δ 4= ∇
Image Analyst
Image Analyst 2015년 4월 6일
Sounds like homework, so all three of us gave you the identical hint. And it looks like Mahdiyar gave you a full answer that is what I think you are asking for.

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


Jan
Jan 2015년 4월 6일
I guess that this is enough:
randi(4, 1, 50)
  댓글 수: 1
Tarek Alnajjar
Tarek Alnajjar 2015년 4월 6일
I donno how to explain my question perfectly but what I need is when I get the result for the random number for exaple:(if the answer was 4 it should wright down or arrow down) or 1= -> 2= <- 3= Δ 4= ∇

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


Tarek Alnajjar
Tarek Alnajjar 2015년 4월 6일
Perfect ! Thanks alot (shokrn ;) )

카테고리

Help CenterFile Exchange에서 Just for fun에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by