Q:

File Write Permission Issue in Matlab

I've been trying to write image files to the specified folder, but I always receive this error:
Unable to open file
"C:\Users\Dani\Desktop\code_version_1.0\myImages"
for writing.  You may not have
write permission.
Is there a way to fix this? Thanks.
for i=1:numberOfFiles 
    filename=fileList{i};
img=imread(filename,'jpg');
image = imresize(img, [150,150]);

folder='C:\Users\Dani\Desktop\code_version_1.0\myImages';
  if ~exist(folder,'dir')
    mkdir(folder);
  end
imwrite(image,folder,'jpg');

end

A:

Your call to imwrite has an invalid second parameter. You gave it a folder when it is asking for a file path.
Here's a possible work-around:
outfile = fullfile(folder, 'output.jpg');
imwrite(image, outfile, 'jpg');

