How to index filenames correctly?

조회 수: 7 (최근 30일)
Valeska Pearson
Valeska Pearson 2013년 8월 31일
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