filepath=pwd; %保存当前工作目录
cd('C:\liver background') %保存到指定目录下
imwrite(patch,['liver background',num2str(t),'.bmp']) %命名一系列图片名
imwrite(end_patch_label,'liver background label.bmp'); %将bmp图片保存到当前目录
cd(filepath) %切回原工作目录
参考博客:https://blog.youkuaiyun.com/songyunli1111/article/details/79622374