Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
saving the variables in for loop

Subject: saving the variables in for loop

From: raghda

Date: 8 Dec, 2012 23:19:08

Message: 1 of 2

plz i have this code
 for i=1:26
     imFilename = sprintf('DB/%d.jpg', i);
     [im , des , loc ] = sift(imFilename,i);
end
and i need for each iteration , the output is saved likes "im1 des1 loc1 for the first saved file and im2 des2 loc2 for the secon saved file... " by function save ('filename.mat') but i need it for each "i"

Subject: saving the variables in for loop

From: Sadik

Date: 10 Dec, 2012 01:48:16

Message: 2 of 2

Hi Raghda,

Some people in this newsreader have an allergy against the function eval, but you can do this:

for i=1:26
     imFilename = sprintf('DB/%d.jpg', i);
     eval(['[im' num2str(i) ', des' num2str(i) ', loc' num2str(i) '] = sift(imFilename,i);'])
end

Best.

"raghda " <zezo.abeer@yahoo.com> wrote in message <ka0htc$m14$1@newscl01ah.mathworks.com>...
> plz i have this code
> for i=1:26
> imFilename = sprintf('DB/%d.jpg', i);
> [im , des , loc ] = sift(imFilename,i);
> end
> and i need for each iteration , the output is saved likes "im1 des1 loc1 for the first saved file and im2 des2 loc2 for the secon saved file... " by function save ('filename.mat') but i need it for each "i"

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us