Using Datetiim to produce array of time points
조회 수: 2 (최근 30일)
이전 댓글 표시
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. }
댓글 수: 0
채택된 답변
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.
댓글 수: 0
추가 답변 (2개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!