How do I ask for a string input?
20 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hakob Enfiajyan
am 7 Okt. 2022
Kommentiert: Star Strider
am 9 Okt. 2022
n=input("Number of files: ");
for i=1:n
FileName(i) = input("File Name: ","s");
Here is my code which ends up giving me an error message saying
I'm simply asking for a string and inputting it into FileName which should hold all the string
Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
Error in DataReader (line 6)
FileName(i) = input("File Name: ","s");
What am I doing wrong? Just 20 minutes ago my code was working perfectly fine
0 Kommentare
Akzeptierte Antwort
Star Strider
am 7 Okt. 2022
It is likely easier to save it to a cell array —
FileName{i} = input("File Name: ","s");
That worked when I tried it offline.
.
4 Kommentare
Star Strider
am 9 Okt. 2022
As always, my pleasure!
It also leaves the Command Window free, another reason I prefer it.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Startup and Shutdown 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!