Create text string vector
5 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Wayne King
on 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 Comments
See Also
Categories
Find more on Characters and Strings in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!