Coverting Timetable to Column Vector
Mostrar comentarios más antiguos
Hi everyone,
I am working with .edf files and am using edfread, which is giving me a timetable output, when I would like a column vector.
We are recording voltage data in 1-hour increments at a sampling frequency of 1 KHz with 6 channels, each channel is unique.
I am using the option 'DataRecordOutputType' set to 'vector', which just makes this weirder.
Here's the code:
data = edfread('filename.edf','DataRecordOutputType' ,'vector');
and the output is:

I can solve this via doing the following:
data = edfread('filename.edf','DataRecordOutputType' ,'vector');
abf_like = [];
new_data = cell2mat(data{1,1});
abf_like = new_data;
for i = 2:size(data, 1)
new_data = cell2mat(data{i,1});
abf_like = vertcat(abf_like, new_data);
end
Which outputs my desired array (3600500 x 1). But this takes forever (understandably so), and there are 6 channels per edf file and many files. What am I missing with edfread, or what can I do to speed this up?
Thanks for any insight you can offer.
edit: here's something that works for what I need. Still would like some alternatives, if there are any:
clear all; close all; clc
edf = edfread('filename.edf');
abf_like = edf_to_abf(edf);
function out = edf_to_abf(edf)
edf = timetable2table(edf); edf = table2cell(edf);
edf = edf(:, 2:end);
abf_like = zeros(3600500,1);
abf_like = table(abf_like);
for j = 1:6
single_data = edf(:,j);
abf_like{:,j} = unpacker(single_data);
clear single_data
end
out = table2array(abf_like);
end
function out = unpacker(data)
abf_like(:,1) = cell2mat(data(1,1));
r = 501;
for i = 2:size(data, 1)
abf_like(r:r+499,1) = cell2mat(data(i,1));
r = r + 500;
end
out = abf_like;
end
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Text Analytics Toolbox en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!