From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Save matrix in a loop
Date: Mon, 15 Jul 2013 08:07:10 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 18
Message-ID: <ks0aje$o7e$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1373875630 24814 (15 Jul 2013 08:07:10 GMT)
NNTP-Posting-Date: Mon, 15 Jul 2013 08:07:10 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 4253316
Xref: comp.soft-sys.matlab:799312


this is my code to segment all images in testing folder..the problem is,i want to save each matrix data in different .mat file using a loop..i dont know how to do it

clear all
srcFiles = dir('\MSc AIA\amazon images\1-1000\testing\*.jpg'); 
for i = 1 : length(srcFiles)
filename = strcat('\MSc AIA\amazon images\1-1000\testing\',srcFiles(i).name);
I = imread(filename); 
level = graythresh(I);
BW = im2bw(I,level);
pathname = '\MSc AIA\amazon images\1-1000\testing\segmented';
segment = sprintf('%d.bmp', i);
fullfilename = fullfile(pathname, segment);
imwrite(BW, fullfilename);