フィルターのクリア

Problem using "datetime"

7 ビュー (過去 30 日間)
Andy Wileman
Andy Wileman 2021 年 3 月 16 日
コメント済み: Andy Wileman 2021 年 3 月 17 日
Hi,
I'm trying to import data from a structure and save it as a file with the data in the filename. See my previous problems. I have got as far as the code below, but have run into the following problem:
Error in extractor (line 14)
T = table(N, 'VariableNames', {'Dates'})
Caused by:
You might have intended to create a one-row table with the
character vector '12/24/2008 9:59:47 AM.786743640' as one
of its variables. To store text data in a table, use a
string array or a cell array of character vectors rather
than character arrays. Alternatively, create a cell array
with one row, and convert that to a table using
CELL2TABLE.
My code is a follows, it shows the current date format stored in dateName and the filename I would like to store the data in timeDom under.
load('Device2_13032021.mat');
L = length(measurement.transient);
for i = 1:L
dateName = {measurement.transient(i).date};
timeDom = {measurement.transient(i).timeDomain};
%Current file format{'12/24/2008 9:59:47 AM.786743640'}
%Fileformat to convert to = data-20130325T004512Z.mat
date=cell2mat(dateName);
data=cell2mat(timeDom);
N = date
T = table(N, 'VariableNames', {'Dates'})
t = datetime(T.Dates,'ConvertFrom', 'dd/mm/yyyy''T''HHmmss''Z');
% TODO: Save files
save(data, '-append', '-struct', 't');
%
end
I would be grateful if anyone could shed some light on where things have gone wrong.
Kind regards,
Andy
  1 件のコメント
Adam Danz
Adam Danz 2021 年 3 月 16 日
If you format your code, it would be much easier to read.
See the "text/code" toggle button: https://www.mathworks.com/matlabcentral/help/rtc

サインインしてコメントする。

採用された回答

Adam Danz
Adam Danz 2021 年 3 月 16 日
T = table(string(N), 'VariableNames', {'Dates'})
  1 件のコメント
Andy Wileman
Andy Wileman 2021 年 3 月 17 日
Thank you Adam.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTables についてさらに検索

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by