"Invalid Handle" error message occurs

2 ビュー (過去 30 日間)
Don
Don 2017 年 10 月 31 日
コメント済み: Don 2017 年 10 月 31 日
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?

採用された回答

Fangjun Jiang
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.
  1 件のコメント
Don
Don 2017 年 10 月 31 日
That seemed to fix it. Thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT-Files についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by