I imagine that our_images
is the name of the folder when you want your images, so instead of this:
name=strcat((int2str(our_images)),'\',imagename);
you need this:
name=strcat(our_images,'/',imagename);
Also look out for the backslash in there.
Also your name
variable should not be quoted here:
imwrite(rgbBlock,'name');
So instead it should be:
imwrite(rgbBlock, name);