Using Datetiim to produce array of time points

조회 수: 2 (최근 30일)
Del Ventruella
Del Ventruella 2017년 5월 3일
답변: Del Ventruella 2017년 5월 3일
I'm trying to use the Datetime function to produce an array of data points to use as input to an array of impedance values to process and plot. I have entered 8 points for Year, Month, and Day. MATLAB claims this is what it wants, even while it denies the Datetime function and won't work. How can I get this data entered into numerical Year,Month, Day for plotting and analysis?
The datetime function is described here:
https://www.mathworks.com/help/matlab/ref/datetime.html
Thanks.
Sincerely,
Del Ventruella
{ >> Y=[2000;2007;2009;2011;2012;2013;2014;2015]
Y =
2000
2007
2009
2011
2012
2013
2014
2015
>> M = [2;2;2;4;8;11;12;11]
M =
2
2
2
4
8
11
12
11
>> D = [12,17,14,16,8,11,13,14]
D =
12 17 14 16 8 11 13 14
>> X = datetime(Y,M,D) Error using datetime (line 579) Data inputs must be the same size, or any of them can be a scalar.
>> len(Y)= len(Y)= ↑ Error: Expression or statement is incomplete or incorrect.
>> length(Y)
ans =
8
>> length(M)
ans =
8
>> length(D)
ans =
8
>> x = datetime(Y,M,D) Error using datetime (line 579) Data inputs must be the same size, or any of them can be a scalar. }

채택된 답변

Steven Lord
Steven Lord 2017년 5월 3일
Look at the size of the variables Y, M, and D. One of these things is not like the others. Just because two arrays have the same number of elements or the same length does not mean they have the same size. Transpose your D variable and it will work.

추가 답변 (2개)

Del Ventruella
Del Ventruella 2017년 5월 3일
That's what I did. I still have a problem in that I'm trying to use the dateTime array as in input for the X-axis components of curvefit toobox. It won't recognize the dateTime array. Is there some way I can convert dateTime to an array of numbers?

Del Ventruella
Del Ventruella 2017년 5월 3일
Perhaps the number of days that have passed since 2000?

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by