How to index filenames correctly?

7 次查看(过去 30 天)
Please help if you have the answer.
I have .png images, which I want to read randomly and send to a function which will perform segmentation and then output the answer in a xls file or csv... But I doing the indexing in the beginning wrong. Here is what I want to do.
store files in Images:
Images=['image001.png'; 'image003.png'; 'image020.png';'image022.png';'image024.png';'image025.png'; 'image026.png';'image027.png';'image028.png';'image029.png';
'image035.png';'image036.png';'image038.png';'image042.png']
Then by choice have the index as follow:
Items=[1 2 5 6 9 12];
I want the 1st, the 2nd, 5th etc...
Then run a loop
for k=1:size(Items,1)
[A,n] = Calc_Exudate(Images(Items(k)));
%append A n to xls or csv
dlmwrite('data.csv',[mat2str(A') ',' num2str(n)],'delimiter',',','-append');
end
With this code it select "i", because that is the 1st letter, but I want the whole file/item.

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2013-8-31
编辑:Azzi Abdelmalek 2013-8-31
Use
[A,n] = Calc_Exudate(Images(Items(k),:));
% or use a cell array
Images={'image001.png';'image003.png';'image020.png';'image022.png'}
[A,n] = Calc_Exudate(Images{Items(k)});

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by