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?

采纳的回答

Walter Roberson
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 个评论
Troy Steiner
Troy Steiner 2016-1-18
Really new to matlab, sorry. so here are the 9 variables:
topoutward = [topleftoutward toprightoutward];
bottominward = [bottomleftinward bottomrightinward];
topinward = [topleftinward toprightinward];
bottomoutward = [bottomleftoutward bottomrightoutward];
inwardmean = mean(mean(imageedit_inward));
outwardmean = mean(mean(imageedit_outward));
topinwardmean = mean(mean(topinward));
bottominwardmean = mean(mean(bottominward));
topoutwardmean = mean(mean(topoutward));
bottomoutwardmean = mean(mean(bottomoutward));
fullratio = inwardmean/outwardmean;
topratio = topinwardmean/topoutwardmean;
bottomratio = bottominwardmean/bottomoutwardmean;
Are you suggesting I need to add this in to the "nine_stats" variable? Would the top line read filename = sprintf('*.bmp', K)?
Walter Roberson
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 CenterFile Exchange 中查找有关 Cell Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by