send variables to menu

조회 수: 10 (최근 30일)
Leyon
Leyon 2013년 10월 22일
댓글: Matt Kindig 2013년 10월 22일
The menu function takes string input (text, options). Is there anyway to pass variables to the string. For example:
A = [red blue green] or A = 214
B = menu('You chose: A(1)', 'Y', 'N')
B = menu('You chose: {A}', 'Y', 'N')
Or do I have to do it the long way with fprintf and if statements?
  댓글 수: 1
Matt Kindig
Matt Kindig 2013년 10월 22일
편집: Matt Kindig 2013년 10월 22일
The first input to menu() is just a string. So you can pass in any string that can you can compose from your variables. Why not do something like this:
A = 214
B = menu( sprintf('You choose %f', A(1)), 'Y', 'N')
A = {'red','green','blue'}
B = menu( sprintf('You choose %s', A{1}), 'Y', 'N')

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Numeric Types에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by