Write the Timetable data to the EDF file
古いコメントを表示
>> hdr = edfheader("EDF");
>> hdr.NumSignals = 3;
hdr.NumDataRecords = 3;
>> edfw = edfwrite("rand.edf",hdr,TT);
Incorrect use of edfwrite
annotations should be arrays with columns equal to 2.
But I haven't annotations
How can I write a Timetable data into a EDF File?
2 件のコメント
Shashi Kiran
2024 年 9 月 2 日
I used edfwrite on my data without annotations, and it worked fine. Could you share your Timetable data(TT) so I can look into it further?
Wensor
2024 年 9 月 2 日
編集済み: Walter Roberson
2024 年 9 月 3 日
採用された回答
その他の回答 (1 件)
I see you are using edfwrite on timetables. The edfwrite function is specifically designed to work with numerical data, not with timetables. However, you can convert the timetable to a numeric matrix and then use edfwrite to write the data to an EDF file.
Below is an implementation based on the data you have provided:
% Create timetable with your data
MeasurementTime = datetime({'2015-12-18 08:03:05'; '2015-12-18 10:03:17'; '2015-12-18 12:03:13'});
Temp = [37.3; 39.1; 42.3];
Pressure = [30.1; 30.03; 29.9];
WindSpeed = [13.4; 6.5; 7.3];
TT = timetable(MeasurementTime, Temp, Pressure, WindSpeed);
% Prepare signal data
sigdata = [TT.Temp, TT.Pressure, TT.WindSpeed];
% Prepare the EDF Header
hdr = edfheader("EDF");
hdr.NumSignals = 3;
hdr.NumDataRecords = height(TT);
hdr.DataRecordDuration = duration(0, 0, 0.1);
% Specify signal labels and other properties
hdr.SignalLabels = ["Temperature"; "Pressure"; "Wind Speed"];
hdr.PhysicalDimensions = ["C"; "hPa"; "m/s"];
hdr.PhysicalMin = [min(Temp); min(Pressure); min(WindSpeed)];
hdr.PhysicalMax = [max(Temp); max(Pressure); max(WindSpeed)];
hdr.DigitalMin = [-32768; -32768; -32768];
hdr.DigitalMax = [32767; 32767; 32767];
% Write the data to an EDF file
edfw = edfwrite("rand.edf", hdr, sigdata);
disp(edfw)
Ensure that you have correctly defined the EDF header according to your requirements.
Refer the below documentation for more information regarding edfwrite
Hope this helps!
3 件のコメント
Wensor
2024 年 9 月 2 日
Since we cannot use datetime directly in the EDF file, we can use relative time to store the time data in hours or minutes as required.
Here is the revised code as per your requirement.
% Create timetable with your data
MeasurementTime = datetime({'2015-12-18 08:03:05'; '2015-12-18 10:03:17'; '2015-12-18 12:03:13'});
Temp = [37.3; 39.1; 42.3];
Pressure = [30.1; 30.03; 29.9];
WindSpeed = [13.4; 6.5; 7.3];
TT = timetable(MeasurementTime, Temp, Pressure, WindSpeed);
timeHours = hours(TT.MeasurementTime - TT.MeasurementTime(1));
sigdata = [timeHours, TT.Temp, TT.Pressure, TT.WindSpeed];
% Prepare the EDF Header
hdr = edfheader("EDF");
hdr.NumSignals = 4;
hdr.NumDataRecords = height(TT);
hdr.DataRecordDuration = duration(0, 0, 0.1);
% Specify signal labels and other properties
hdr.SignalLabels = ["Time", "Temperature", "Pressure", "Wind Speed"];
hdr.PhysicalDimensions = ["h", "C", "hPa", "m/s"]; % Dimensions for each signal
hdr.PhysicalMin = [min(timeHours), min(Temp), min(Pressure), min(WindSpeed)];
hdr.PhysicalMax = [max(timeHours), max(Temp), max(Pressure), max(WindSpeed)];
hdr.DigitalMin = [-32768, -32768, -32768, -32768];
hdr.DigitalMax = [32767, 32767, 32767, 32767];
% Write the data to an EDF file
edfw = edfwrite("rand.edf", hdr, sigdata);
disp(edfw)
カテゴリ
ヘルプ センター および File Exchange で Spectral Measurements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

