Create text string vector

4 visualizzazioni (ultimi 30 giorni)
Stefanie Wiese
Stefanie Wiese il 5 Gen 2012
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

Risposte (1)

Wayne King
Wayne King il 5 Gen 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

Categorie

Scopri di più su Characters and Strings in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by