Creating Histogram using .mat file

조회 수: 3 (최근 30일)
Sclay748
Sclay748 2020년 8월 18일
댓글: Sclay748 2020년 8월 18일
Hello,
I am trying to create a histogram. I used a .mat file to create a 1x5000 structure. I am trying to plot only 1000 out of the 5000, so I call 'a' and set the length to 1000 in a for loop, but it says it is only plotting one data point instead of them all. Any idea what I am doing wrong? Thanks!
  댓글 수: 2
Stephen23
Stephen23 2020년 8월 18일
1000 is a scalar number, so length(1000) is one, so your loop will iterate exactly once.
Sclay748
Sclay748 2020년 8월 18일
ahh I thought if I changed x from a(i).time; to a(1).time; then that would be scalar and only print time once at the first row. Thought I was safe putting it in the length.
How would I fix this so it isn't scalar and includes all 1000 points?

댓글을 달려면 로그인하십시오.

채택된 답변

Cris LaPierre
Cris LaPierre 2020년 8월 18일
I suspect your don't really want to create 1000 histograms. You don't need a for loop.
Try
histogram([a(1:1000).time])
  댓글 수: 7
Cris LaPierre
Cris LaPierre 2020년 8월 18일
I think you'd have to do it like this:
histogram([a(1:1000).time]/1e3)
Sclay748
Sclay748 2020년 8월 18일
ahh that did it, thank you!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by