To convert .continuous to .mat
5 次查看(过去 30 天)
显示 更早的评论
Hi everyone,
I need to convert my files ".continuous" in file ".mat", my code is this:
cd(path of directory where there are the files)
dir = dir('*continuous');
cell = struct2cell(dir);
stringa = string(cell);
channels = [];
for i = 1:size(dir,1);
channels(:,i)=load_open_ephys_data_faster([stringa]);
end
But the error is: Error using strcmp
Inputs must be the same size or either one can be a scalar.
How can I resolve this?
Thank you so much!
0 个评论
回答(1 个)
Voss
2022-12-26
Try this:
% you'll need to clear the variable dir (and you might as well clear the
% variable cell too) if this is a script and you still have them in your
% workspace (see more below):
clear dir cell
% store your directory as path_name
path_name = 'path\of\directory\where\the\files\are\';
% - use path_name in call to dir() (no need to cd())
% - don't make a variable called dir (or cell) - that conflicts with the
% built-in function dir() (cell())
% - use '*.continuous' to match files with .continuous extension
d_info = dir(fullfile(path_name,'*.continuous'));
% no need to convert the struct array returned by dir() into a cell
% array and then a string array; just use the struct array directly.
file_names = fullfile({d_info.folder},{d_info.name});
channels = [];
for ii = 1:numel(file_names)
channels(:,ii) = load_open_ephys_data_faster(file_names{ii});
end
1 个评论
Voss
2022-12-26
Another thing to consider is that you can take advantage of the struct array of file info you already have (which was returned from dir()), and use it to store the data from each file as well ...
d_info = dir(fullfile(path_name,'*.continuous'));
file_names = fullfile({d_info.folder},{d_info.name});
for ii = 1:numel(file_names)
d_info(ii).data = load_open_ephys_data_faster(file_names{ii});
end
... instead of storing all the data in a single matrix, which wouldn't even work if the data returned by load_open_ephys_data_faster is not the same length for each file, or if it's not a vector, etc.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 File Operations 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!