Expected timetable data to be numeric.
2 次查看(过去 30 天)
显示 更早的评论
I am trying to do a sftf(x) function, I have compiled the data and datetime has been combined using:
data = 'TA';
for date = datetime(date, 'InputFormat', 'dd-MM-yyyy hh:mm:ss')
end
I keep getting the error Error using signal.internal.utilities.validateattributesTimetable>localCheckAttribute
Expected timetable data to be numeric.
I am unsure where I'm going wrong. Is the imput of date/time incorrect?
Would using a DateVector be useful? I have 57001 rows in each variable (several variables per brain area, and 12 brain areas), it will be impossible to type it all out as e.g. [2014 10 24 12 45 07]. I have no idea how to do it for all rows.
2 个评论
Stephen23
2023-2-16
编辑:Stephen23
2023-2-16
It is unclear what this code is supposed to do:
data = 'TA';
for date = datetime(date, 'InputFormat', 'dd-MM-yyyy hh:mm:ss')
end
Why write a loop with nothing in it? Why define DATA but not use it? How does this relate to your screenshot?
"I am unsure where I'm going wrong. Is the imput of date/time incorrect?"
We don't know either, because we have no idea what DATE is. Nore what TT is in your screenshot.
Your screenshots show that you apparently call some functions, but we have no idea what is in those functions.
If you want help debugging this please upload your code files by clicking the paperclip button.
采纳的回答
Star Strider
2023-2-16
编辑:Star Strider
2023-2-16
It would help to have the data.
I am not certain how the ‘date’ and ‘time’ values are being imported.
One possibility:
DateTime = datetime(TT.date, 'InputFormat','dd/MM/yyyy') + timeofday(datetime(TT.time, 'InputFormat','HH.mm.ss'))
It would also be helpful to know what the ‘time’ values represent. Something like this may be necessary —
time = {'14.11.0020'; '14.11.0021'}
HHmmssSS = cellfun(@(x){x(end-9:end-8) x(end-6:end-5) x(end-3:end-2) x(end-1:end)},time, 'Unif',0);
timec = cellfun(@(x)sprintf('%02d:%02d:%02d.%02d',str2double(x)),HHmmssSS, 'Unif',0);
T = datetime(timec, 'InputFormat','HH:mm:ss.SS', 'Format','HH:mm:ss.SS')
For whatever reason, 'InputFormat','HH.mm.ssSS' fails here.
EDIT — (16 Feb 2023 at 18:27)
Corrected typographical errors. Code unchanged.
.
17 个评论
Walter Roberson
2023-2-16
filename = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/1298125/sample_left_cing_table.csv';
T = readtable(filename)
class(T.time)
class(T.time(1))
T.time(1)
T.time(1).Format
readtable() by default is interpreting the time column as dd.MM.uuuu not as text . You would have to break part the pieces and reconstruct them, or else you would have to use readtable options to tell it that the variable should be text.
options = detectImportOptions(filename);
options = setvartype(options, 'time', 'char');
T = readtable(filename, options)
class(T.time)
class(T.time(1))
T.time(1)
dt = datetime(T.time, 'InputFormat', 'HH.mm.ss');
dt = dt - dateshift(dt, 'start', 'day');
T.date = T.date + dt;
T.date.Format = 'yyyy-MM-dd HH:mm.ss'
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calendar 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!