How to make interactive elements in a GUI

3 views (last 30 days)
Arvind
Arvind on 22 Jan 2013
Hello, I am making a matlab GUI that will simulate a series of dice rolls.
I need to be able to press a button that will generate two random numbers between 1-6, display these in a text box, and display the total in another text box.
Additionally, I have another part of the GUI where I will have a text box where the user can enter in a number indicating the number of dice rolls desired. Then, the probability distribution of which numbers are rolled will show up on an axis element.
In other words, I need to have a probability distribution like the following -
2 - 2.78%
3 - 5.56%
4 - 8.33%
5 - 11.11%
6 - 13.89%
7 - 16.67%
8 - 13.89%
9 - 11.11%
10 - 8.33%
11 - 5.56%
12 - 2.78%
but in bar graph form.
I already have the logic behind the dice rolling set. I can generate dice rolls and their sum, and I can efficiently roll up to 10^8 dice and have the probability distribution in numerical form.
Can someone give me advice on how to make GUI elements interact? I'm kind of new to this.
  1 Comment
Lester Lim
Lester Lim on 22 Jan 2013
In matlab, type in guide. Open a new file, there will be a few buttons at the side. Play around with it. after you have drawn a button you want, right click, callback. Put the code into it. Sorry cant help much more...

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 22 Jan 2013
This is extremely well covered in Doug's video tutorials: http://blogs.mathworks.com/videos/category/gui-or-guide/

Community Treasure Hunt

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

Start Hunting!