Plot frequency in a histogram

7 visualizaciones (últimos 30 días)
Rosalie van der Weide
Rosalie van der Weide el 24 de Mayo de 2018
Editada: Image Analyst el 24 de Mayo de 2018
Hello! I am a beginner in matlab and have a question about plotting relative frequency in matlab. The case : I have a vector of zeros and ones and I wanted to count the frequency of 1's and 0's in the vector. I used the code : nnz(click==1). My vector is called click. The amount of clicks was 48 and bookings 68 (click==0). Now I want to show the percentage of bookings/clicks on the y axis and on the x as I want to have 2 bars of the amount of clicks and the amount of bookings. I am searching for hours now and have no idea how to plot this. Can someone help me out? Thank you in advance!
  3 comentarios
Rosalie van der Weide
Rosalie van der Weide el 24 de Mayo de 2018
Thank you for your fast response! That works indeed! There only remains a question about assigning names to the bars in the histogram. What I want is the following: Instead of numeric values on the x-axis I want to say that the the first bar show the amount of clicks, the second bar the amount of bookings in the histogram. So, I want to replace the x-axis with the current range of 0 to 1, with the words 'clicking' and 'booking'. Is this possible?
Star Strider
Star Strider el 24 de Mayo de 2018
Editada: Image Analyst el 24 de Mayo de 2018
See my Answer below.

Iniciar sesión para comentar.

Respuesta aceptada

Star Strider
Star Strider el 24 de Mayo de 2018
I am not certain what you want.
Try this:
click = randi([0 1], 1, 100); % Create Vector
clix = nnz(click);
book = nnz(click == 0);
N = numel(click);
figure
bar([clix;book]/N)
set(gca, 'XTickLabel',{'Clicks','Bookings'})

Más respuestas (0)

Categorías

Más información sobre Histograms en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by