Including the filename in a matrix with many other values
1 view (last 30 days)
Show older comments
Troy Steiner
on 18 Jan 2016
Commented: Walter Roberson
on 19 Jan 2016
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 Comments
Accepted Answer
Walter Roberson
on 18 Jan 2016
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 Comments
Walter Roberson
on 19 Jan 2016
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
More Answers (0)
See Also
Categories
Find more on Cell Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!