how to select name at random from list of names in text file?

I have text file that has list of names, and I want to choose one name in the list at random.
I want the names to flash one after another and then stop at one name at random ( the same method that use to select winner at random on some TV shows).

1 件のコメント

Jan
Jan 2011 年 3 月 1 日
Do you have a question concerning a specific problem or Matlab?

サインインしてコメントする。

回答 (1 件)

Matt Tearle
Matt Tearle 2011 年 3 月 1 日

0 投票

General approach:
  1. Read the names from file into a cell array of strings -- see textscan
  2. Make a figure window with uicontrol textboxes
  3. Set the String property of each textbox to one of the strings in the cell array (ie names)
  4. Randomly select an integer from 1 to n (see randi)
  5. Change the color (or whatever property) of the chosen textbox
  6. Repeat some number of times, after a short pause
(Or cycle through in order, stopping at a random point, if you prefer.)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

質問済み:

2011 年 3 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by