필터 지우기
필터 지우기

How to put dates on de x-axis

조회 수: 4 (최근 30일)
FC93
FC93 2016년 10월 21일
댓글: FC93 2016년 10월 22일
I have a vector with different values. I want to plot it and that on the x axis the dates appear. I don't have any vectors with dates. The years should go from 1951 until 2014. How can I put now this years on the x axis? I only have the vector with the values that I want to plot, but this vector does not contain any dates.
Thank you for your help

채택된 답변

Chaya N
Chaya N 2016년 10월 21일
편집: Chaya N 2016년 10월 21일
If each of the values in your vector were to be associated with their corresponding dates, then you could plot them. A simple way to do this would be to create a new vector with only the date values and plot as:
plot(<vector of dates>, <vector of data values>)
NOTE: The number of date values that you have should be equal to those in your vector.
For example, if your vector was some x = [1,2,3,4,5] (5 elements), then you would create date_vec = [1951:1955] (also should have 5 elements) and then use plot(date_vec, x).
  댓글 수: 1
FC93
FC93 2016년 10월 22일
Thank you for your help. This was exactly what I was searching.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by