Including the filename in a matrix with many other values
1 次查看(过去 30 天)
显示 更早的评论
New to matlab. I have a program that opens many images and spits back values for each variable; each line represents a new image and has 9 variables seperated by a space. I can't find a way to get it to tell me which file it has open to give me those values. Can anyone help?
0 个评论
采纳的回答
Walter Roberson
2016-1-18
Use a cell array if you need it as a variable. For example,
for K = 1 : 10
filename = sprintf('ghoatkidney_%02d.bmp', K);
thisimage = imread(filename);
nine_stats = calculate_some_statistics(thisimage);
nine_stats_cell = num2cell(nine_stats);
outputs{K,1} = filename;
outputs{K,2:10} = nine_stats_cell{:};
end
2 个评论
Walter Roberson
2016-1-19
nine_stats = [inwardmean, outwardmean, topinwardmean, bottominwardmean, topoutwardmean, bottomoutwardmean, fullratio, topratio, bottomratio];
and
filename = sprintf('%d.bmp', K);
if the file names are to be 1.bmp 2.bmp 3.bmp ... 10.bmp 11.bmp and so on.
If the file names are to be extracted from a directory then see
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Cell Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!