Could anyone explain what is the role of vector x in, polarhisto​gram(deg2r​ad(200),x) ;given x=(0:10:360)*3.14/180 ?

2 vues (au cours des 30 derniers jours)
1)Could anyone explain what is the role of vector x in,
>> x=(0:10:360)*3.14/180;
>> polarhistogram(deg2rad(200),x)
2)And how the above code and below code is giving almost same output, even though in code below, we use only one bin value=5 and above we use x vector having 37 elements(from 0 to 360 at spacing of 10)
>>polarhistogram(deg2rad(200),5)

Réponse acceptée

Cris LaPierre
Cris LaPierre le 11 Nov 2022
Modifié(e) : Cris LaPierre le 11 Nov 2022
Looking at the possible syntaxes for calling polarhistogram, I draw the following conclusions:
For 1, x must be specifying the edges.
For 2, 5 must be specifying the number of bins.
You get the same result either way because you are creating your histogram with a single value: deg2rad(200). The difference would be more noticeable if you have many values.
theta = deg2rad(randi(360,1000,1));
x=(0:10:360)*3.14/180;
tiledlayout(1,2)
nexttile
polarhistogram(theta,x)
nexttile
polarhistogram(theta,5)
  3 commentaires
Cris LaPierre
Cris LaPierre le 11 Nov 2022
Modifié(e) : Cris LaPierre le 11 Nov 2022
The edges are there, but the count is 0 in all but 1 of your bins, so you can't see them. The height of the bar corresponds to the number of elements of theta that fall within the bin.
Below you see a polarhistogram where there is 1 element in each bin defined by x (blue), and then on top of that, the polarhistogram for a single value of (red). The edges are the same in both, but you only see one red bar because only 1 bin has a count >0.
x=(0:10:360)*3.14/180;
polarhistogram(deg2rad(1:10:360),x)
hold on
polarhistogram(deg2rad(200),x)
hold off
Please see the links I shared in my original answer for the definition of bins vs edges. When you define edges, you manually create the interval for binning your data. When you specify nbins, MATLAB automatically generates the intervals to give you that number of equally-spaced bins.
So x=(0:10:360) defines 36 bins, each with an interval of 10 degrees, while specifying nbins of 5 creates 5 bins, each with an interval of 72 degrees.
Riya sharma
Riya sharma le 11 Nov 2022
Thanx alot Cris. You explained to the point and crisp.It resolved my query.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by