"Invalid Handle" error message occurs
2 次查看(过去 30 天)
显示 更早的评论
I have the following very simple code:
fprintf(' Select Folder to store output plots and files \n');
FigPath = uigetdir('C:\Projects', ' Select Folder to store output plots ');
%FigPath = cat(2,FigPath,'\');
name = cat(2,name,'.png');
saveas(FigPath,name); % save plot to subj directory
Other Matlab programs have the very same code and work fine. Note that the %-statement adds a backslash, which doesn't help either.
Please: what's going on?
0 个评论
采纳的回答
Fangjun Jiang
2017-10-31
Pay attention to the syntax of saveas(). The first argument should be the handle of the figure, not the path of your saved file.
Also, fullfile() might be better than cat() in your case.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Workspace Variables and MAT-Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!