MATLAB: Imwrite filename

imwrite

Dear all, How can I save an image with the file name being the value of a variable?
The following code works in exporting the image but not in assigning the file name the way I need.
R is the name of the variable…
Thanks, Diego
Matlab code
imwrite(X.cdata, 'R''.png')

Best Answer

Thank you Fangjun and Image Analyst. Your tip Fangjun point me to the answer.
imwrite(X.cdata, [R{1}, '.png'])
Regards,
Diego