Expected timetable data to be numeric.
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Antoinette Burger
am 16 Feb. 2023
Kommentiert: Antoinette Burger
am 16 Feb. 2023
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 Kommentare
Stephen23
am 16 Feb. 2023
Bearbeitet: Stephen23
am 16 Feb. 2023
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.
Akzeptierte Antwort
Star Strider
am 16 Feb. 2023
Bearbeitet: Star Strider
am 16 Feb. 2023
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 Kommentare
Walter Roberson
am 16 Feb. 2023
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'
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Calendar finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!