0

I have a set of input image (im1,im2,im3,im4,im5; all have the size of [200 200]) and I want to resize them based on the matlab code: resized = imresize(input image,[100 100],'nearest').

I want to resize them and save them in different matrices 9such as out1, out2, out3, out4, out5).

I am suing the following code but it does not work, any solution?

for i = 1:5
  varName = ['im' int2str(i)];  % output string
  eval(['out' varName ' = imresize(' varName ',[100 100], 'nearest');']);
end
Sam
  • 939
  • 5
  • 14
  • 41
  • It says that it contains invalid statement and I don't know that how I should correct it! – Sam Mar 06 '14 at 20:43
  • 1
    Do not use `eval` unless absolutely necessary. I don't see it here as a necessity. You can read all the images in a folder as shown [here](http://stackoverflow.com/a/15657570/1586200). Then resize. I would go further and say that using `eval` here is a bad idea. What if images were named randomly and not in order? – Autonomous Mar 06 '14 at 20:46

1 Answers1

1

Try this:

eval(['out' varName ' = imresize(' varName ',[100 100], ''nearest'');']);
lennon310
  • 12,503
  • 11
  • 43
  • 61