Use a variable in Request user input prompt.
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Emmanouil Barmpounakis
le 9 Juil 2015
Commenté : Emmanouil Barmpounakis
le 9 Juil 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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/152015/image.png)
Any solutions?
2 commentaires
Réponse acceptée
Brendan Hamm
le 9 Juil 2015
Modifié(e) : Brendan Hamm
le 9 Juil 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
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur LaTeX dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!