Filter löschen
Filter löschen

Use a variable in Request user input prompt.

2 Ansichten (letzte 30 Tage)
Emmanouil Barmpounakis
Emmanouil Barmpounakis am 9 Jul. 2015
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 Kommentare
Azzi Abdelmalek
Azzi Abdelmalek am 9 Jul. 2015
What is your problem? What are you expecting as result?
Emmanouil Barmpounakis
Emmanouil Barmpounakis am 9 Jul. 2015
Azzi, see the accepted answer below by Brendan Hamm. Thank you for your time.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Brendan Hamm
Brendan Hamm am 9 Jul. 2015
Bearbeitet: Brendan Hamm am 9 Jul. 2015
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

Weitere Antworten (0)

Kategorien

Mehr zu Software Development Tools finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by