for i=1:10
url= strcat('C:\picture\',num2str(i),'.bmp');
imwrite(I,url);
end;
大概结构就是这样的,每次i变化,写入和读取的地址就会变化,这个网上很多,搜一下就有了
path0 = 'C:\picture\';
for J = 1:10
path = [path0 num2str(J) '\'];
for f = 1:10
fnm = [path num2str(f) '.jpg'];
I = imread(fnm);
g = rgb2gray(I);
imwrite(g,fnm);
end;
end;