How to store strings into array?
显示 更早的评论
I am reading filename from directory and want to store it into array.
srcFiles = dir('E:\abc\*.bmp'); % the folder in which ur images exists
for i = 1 : length(srcFiles)
filename = strcat('E:\abc\',srcFiles(i).name);
names(i,:)=filename;
end
I am getting following error ??? Undefined function or variable 'names'.
3 个评论
Why waste your time with a loop anyway ?
P = 'E:\abc\';
S = dir(fullfile(P,'*.bmp');
N = {S.name};
F = fullfile(P,N)
Azzi Abdelmalek
2016-8-26
You don't need cellfun
F=fullfile(P,N)
Stephen23
2016-8-26
@Azzi Abdelmalek: thank you, I changed the comment.
采纳的回答
更多回答(1 个)
Azzi Abdelmalek
2016-8-26
names=fullfile('E:\abc\',{srcFiles.name})
类别
在 帮助中心 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!