MATLAB: Am calling a print function: cdata=prin​t(filetosa​ve,’-djpeg​’,’-r0′); which succeeds in writing the file but then throws an error: One or more output arguments not assigned during call to “varargout”. Perhaps you can help

MATLABprint image to file

Am calling a print function: cdata=print(filetosave,'-djpeg','-r0'); which succeeds in writing the file but then throws an error: One or more output arguments not assigned during call to "varargout". Perhaps you can help?
Thanks

Best Answer

According to the doc here:
https://www.mathworks.com/help/matlab/ref/print.html?s_tid=doc_ta
The only form of calling print that returns an output is this one:
cdata = print('-RGBImage');
Since you are not using that form, no output argument is returned and there is nothing to put into your cdata variable, hence the error message. Simply get rid of the cdata stuff in your call:
print(filetosave,'-djpeg','-r0');
Related Question