Use a variable in Request user input prompt.

조회 수: 1 (최근 30일)
Emmanouil Barmpounakis
Emmanouil Barmpounakis 2015년 7월 9일
댓글: Emmanouil Barmpounakis 2015년 7월 9일
I am trying to use the Request User Input command with a changeable message for every iteration. For example:
1 prompt=sprintf('For file %f give the value for x',filename)
2 x = input(prompt)
However filename is a 1x23 char and I don't get the result I get. The code I use, treats filename as a
Any solutions?
  댓글 수: 2
Azzi Abdelmalek
Azzi Abdelmalek 2015년 7월 9일
What is your problem? What are you expecting as result?
Emmanouil Barmpounakis
Emmanouil Barmpounakis 2015년 7월 9일
Azzi, see the accepted answer below by Brendan Hamm. Thank you for your time.

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

채택된 답변

Brendan Hamm
Brendan Hamm 2015년 7월 9일
편집: Brendan Hamm 2015년 7월 9일
The identifier you are using in sprintf (%f) stands for floating point, but you want a char array so use the identifier %s.
>> filename = 'abcdef.csv';
>> prompt=sprintf('For file %s give the value for x',filename)
prompt =
For file abcdef.csv give the value for x

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by