what I have to do to solve the error "Invalid or deleted object." while creation of histogram?

I created a Histogram of the wav file :
[n, fs] = audioread('host.wav');
h = histogram(n);
then histogram has plotted and its porperties were displayed like as follows:
h =
Histogram with properties:
Data: [62747×1 double]
Values: [1×205 double]
NumBins: 205
BinEdges: [1×206 double]
BinWidth: 100
BinLimits: [-9300 11200]
Normalization: 'count'
FaceColor: 'auto'
EdgeColor: [0 0 0]
When i tried to access the poperties of this histogram like
h.NumBins();
it gives an error as given below:
Invalid or deleted object.
Error in matlab.graphics.chart.primitive.Histogram/get.BinEdges
Error in matlab.graphics.chart.primitive.Histogram/get.NumBins
How to resolve this issue? Thanks in Advance

3 Comments

These properties of histogram are going to be so much useful for my implementation. so I need to access them.
Did you close the figure?
Are you using a script or functions?

Sign in to comment.

Answers (1)

Dont close the figure.....if you close the figure obviously you will get this error.

5 Comments

okay , I understood that.
if i closed that figure, then Is there any alternative to access those properties.
Thank You.
Call histogram again, or if you just need the bin counts without the figure call histcounts.
@Steven Lord histcounts() will print the array where colums are numbered as number of bins, not the exact number. Besides Bin Count other properties are also required like 'binwidth'.
Can you please exlpain calling of histogram again?
So call histogram again . Make it invisible if you want. You can create a figure just for this purpose .
Call histogram a second time to recreate the histogram object.
h = histogram(n);

Sign in to comment.

Asked:

on 5 Mar 2019

Commented:

on 5 Mar 2019

Community Treasure Hunt

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

Start Hunting!