Using Datetiim to produce array of time points

2 visualizzazioni (ultimi 30 giorni)
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. }

Risposta accettata

Steven Lord
Steven Lord il 3 Mag 2017
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.

Più risposte (2)

Del Ventruella
Del Ventruella il 3 Mag 2017
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 il 3 Mag 2017
Perhaps the number of days that have passed since 2000?

Categorie

Scopri di più su Dates and Time in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by