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.

Antworten (1)

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

Kategorien

Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Hilfe-Center und File Exchange

Gefragt:

KB
am 20 Sep. 2011

Community Treasure Hunt

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

Start Hunting!

Translated by