The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Save matrix in a loop
Replies: 1   Last Post: Jul 15, 2013 10:38 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 2,359
Registered: 12/6/04
Re: Save matrix in a loop
Posted: Jul 15, 2013 10:38 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"shazwani kamarudin" wrote in message <ks0aje$o7e$>...
> hello~
> 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);
> end

% I'm not sure what"matrix data" you are trying to save,
% but if the rest of your code works,
% couldn't you just add something like:

matfile = sprintf('%d.mat', i);
matfilename = fullfile(pathname, matfile);

% to your existing for loop?

% You might also take a look at Q3.1 & 3.10
% of the MATLAB FAQ at:

% Specifically:



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.