Create text string vector
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I would like to creat a text string vector to import data into Matlab, looking like:
A=['C:\Data\file1.txt'
C:\Data\file2.txt'
C:\Data\file3.txt'
C:\Data\file4.txt'
C:\Data\file5.txt'
C:\Data\file6.txt'
C:\Data\file7.txt']
What I tried to do does not really work out:
for i=1:7
eval(['A=['C:\Data\file' num2str(i) '.txt']']);
end
Would be great, if anybody could help me.
Thanks a lot
0 commentaires
Réponses (1)
Wayne King
le 5 Jan 2012
Hi Stefanie,
How about using a cell array.
A={'C:\Data\file1.txt',
'C:\Data\file2.txt',
'C:\Data\file3.txt',
'C:\Data\file4.txt',
'C:\Data\file5.txt',
'C:\Data\file6.txt',
'C:\Data\file7.txt'};
Then you can use A{1}, A{2}, and so on.
If you want to do it your way:
for nn = 1:5
test = ['c:\data\file' num2str(nn) '.txt'],
end
0 commentaires
Voir également
Catégories
En savoir plus sur Characters and Strings dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!