saveas throws "Invalid Simulink object handle" error

Hello All,
I am trying to save a plot in .png format. I am using a code which looks something like this:
figure (2)
h2 = hist(variable1(:,2),50);
xlabel('Error');
ylabel('Error Distribution');
string1 = strcat('Histogram',10,'Variable1'); %10 is added for \n
title(string1);
saveas(h2,'better_system\hist_variable1.png');
when I run this piece of code, I see the following error:
??? Error using ==> saveas at 73 Invalid Simulink object handle.

回答 (1 件)

TAB
TAB 2011 年 9 月 20 日

0 投票

hist not returns the figure handle. See 'help hist'.
Try
h2=figure(2);
hist(variable1(:,2),50);

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

質問済み:

KB
2011 年 9 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by