Trying to Plot cell array data
조회 수: 3 (최근 30일)
이전 댓글 표시
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
Adam Danz
2020년 10월 31일
편집: Adam Danz
2020년 10월 31일
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?
채택된 답변
Adam Danz
2020년 10월 31일
편집: Adam Danz
2020년 10월 31일
"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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Discrete Data Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
