Trying to Plot cell array data

4 visualizaciones (últimos 30 días)
Mohamed Eltaeb
Mohamed Eltaeb el 30 de Oct. de 2020
Editada: Adam Danz el 31 de Oct. de 2020
So I have a dataset of music data that I am trying to correlate with information collected on the y axis. The data itself is a cell array containing a 2 element list in each index of the cell array, like this below.
1 2 3
[0.5,0.8] [1.3,2.4] [3.7, 6.1]
I want to plot this data as the x-axis against the information collected on the y axis, where between the two numbers in each list, it correlates to the value on the y-axis. This would look similar to a rectangular waveform.
Thanks
Mo
  2 comentarios
Adam Danz
Adam Danz el 31 de Oct. de 2020
Editada: Adam Danz el 31 de Oct. de 2020
You lost me here:
I want to plot this data as the x-axis against the information collected on the y axis, where between the two numbers in each list, it correlates to the value on the y-axis.
I'm assuming the cell array is,
c = { [0.5,0.8], [1.3,2.4], [3.7, 6.1] };
Do you mean those are the x-coordinates?
What are the y coordinates?
What do you mean "Between the two numbers?
Correlation of what?
Mohamed Eltaeb
Mohamed Eltaeb el 31 de Oct. de 2020
Yes the cell array is oriented like you displayed. the two numbers in each list are a range of x coordinate values, so from 0.5 to 0.8, they have the same y value.
What I am trying to do is create a sort of bar graph that has the left most point of the bar start at first value (0.5) in the list and the right most point of the bar end on the second value in the list of the cell array (0.8) and have their y value in that range be equal to 1 y-value which is why itd look like a bar.
I hope that explains it better. Thanks for the help in advance.

Iniciar sesión para comentar.

Respuesta aceptada

Adam Danz
Adam Danz el 31 de Oct. de 2020
Editada: Adam Danz el 31 de Oct. de 2020
"What I am trying to do is create a sort of bar graph that has the left most point of the bar start at first value (0.5) in the list and the right most point of the bar end on the second value in the list of the cell array (0.8) and have their y value in that range be equal to 1 y-value which is why itd look like a bar. "
Bar plots have uniform widths but your bar widths aren't uniform so you cannot use bar().
Histograms can have different widths.
% c is a cell array of 1x2 vectors.
c = { [0.5,0.8], [1.3,2.4], [3.7, 6.1] };
% y is a cell array the same size as c containing scalar values
y = {2,3,4};
% Create plot
cla()
hold on % important
cellfun(@(edges,count)histogram('BinEdges',edges,'BinCounts',count),c,y)
  3 comentarios
Adam Danz
Adam Danz el 31 de Oct. de 2020
Editada: Adam Danz el 31 de Oct. de 2020
Glad I could help!
Mohamed Eltaeb
Mohamed Eltaeb el 31 de Oct. de 2020
Totally

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Discrete Data Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by