I = imread("a.jpg"); imshow(I); % imshowを追加
h1 = drawrectangle('Position',[988,0.500000000000171,3999,3999]);
roi1 = h1.Position;
imgtriming= imcrop(img,roi1);
figure;imshow(imgtriming,"Border","tight");
[file,path] = uiputfile % [名前を付けて保存] ダイアログ ボックスと同様
imwrite(imgtriming,[path filesep file]); % print(指定したフォルダ)