필터 지우기
필터 지우기

To convert .continuous to .mat

조회 수: 1 (최근 30일)
Felicia DE CAPUA
Felicia DE CAPUA 2022년 12월 26일
편집: Jan 2022년 12월 26일
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!

답변 (1개)

Voss
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
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 CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by