Trying to Plot cell array data

3 Ansichten (letzte 30 Tage)
Mohamed Eltaeb
Mohamed Eltaeb am 30 Okt. 2020
Bearbeitet: Adam Danz am 31 Okt. 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 Kommentare
Adam Danz
Adam Danz am 31 Okt. 2020
Bearbeitet: Adam Danz am 31 Okt. 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 am 31 Okt. 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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Adam Danz
Adam Danz am 31 Okt. 2020
Bearbeitet: Adam Danz am 31 Okt. 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 Kommentare
Adam Danz
Adam Danz am 31 Okt. 2020
Bearbeitet: Adam Danz am 31 Okt. 2020
Glad I could help!
Mohamed Eltaeb
Mohamed Eltaeb am 31 Okt. 2020
Totally

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Discrete Data Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by