Include variables in matlab user input

조회 수: 10 (최근 30일)
Josh
Josh 2011년 6월 15일
Hi guys, Basically I just want to use a variable that I've already declared when asking a user for input.
a= input('Pick a letter') b= input('Now ask something about the letter' a '? ')
Something along those lines. Even if I have to convert 'a' to another format after its found would be fine. I've looked over the internet and matlabs help for input a fair bit but can't find anything. Does anyone know if this is possible? Thanks in advance Josh

채택된 답변

Matt Fig
Matt Fig 2011년 6월 15일
Is this what you are after?
a = input('Pick a letter: ','s');
b = input(['Now ask something about the letter ', a, '? '],'s');
  댓글 수: 6
Josh
Josh 2011년 6월 15일
Oh okay, so it's not the commas at all its the square brackets doing the concatenating. Well I've learnt lots today lol. Thanks for the help guys
Matt Fig
Matt Fig 2011년 6월 15일
Yes, I almost always use commas to separate values unless it is a pure list of non-negative numbers.
[2,-3,4,-6,7]
['This ','string ','is built from ','sub-strings.']
but only for non-negative integers
[3 4 5 6 7]
Also, note the other: [1;2;3;4;5]

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by