Effacer les filtres
Effacer les filtres

How do I make a new folder and then name it using the string stored within a variable.

20 vues (au cours des 30 derniers jours)
I have named a variable s2. The string stored within s2 is '3 min RT'.
I want to create a new folder named "3 min RT".
At the moment when I use mkdir s2, the folder created is called s2 and not "3 min RT".
Anyhelp please? Thanks!

Réponses (2)

Alex Mcaulley
Alex Mcaulley le 22 Juil 2019
Modifié(e) : Alex Mcaulley le 22 Juil 2019
  2 commentaires
Stephen23
Stephen23 le 22 Juil 2019
Modifié(e) : Stephen23 le 22 Juil 2019
"this makes a folder named s2"
Only if the variable s2 contains the characters 's2', or is a function returning those characters.

Connectez-vous pour commenter.


Nicholas Byres
Nicholas Byres le 22 Juil 2019
I have now figured this out. I had to use:
mkdir([s2])
including both the square and curly brackets. Can anyone explain exaclty why for future reference?
Thanks
  1 commentaire
Stephen23
Stephen23 le 22 Juil 2019
Modifié(e) : Stephen23 le 22 Juil 2019
"I had to use:"
mkdir([s2])
"including both the square and curly brackets."
There are no curly braces in your code.
The parentheses are either indexing or calling a function:

Connectez-vous pour commenter.

Catégories

En savoir plus sur Data Type Conversion 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!

Translated by