MATLAB: Saving with filename from excel

saveas

Hi
I getting text from excel cell A1. This value changes for different dataset.
Question: How to use it as a filename for saving image.
I am currently using saveas(gcf,'Test.jpg');
or saveas(gca, fullfile(folderName, 'Test'),'jpeg');
Thanks

Best Answer

It does not work because the string contained in fname is wrapped inside a cell.
You must convert the cell to the data type contained within it.
Use:
saveas(gcf,cell2mat(fname),'jpg')