saving multiple .mat files different names

조회 수: 7 (최근 30일)
Eva Maria Deltor Cortés
Eva Maria Deltor Cortés 2020년 1월 29일
댓글: Eva Maria Deltor Cortés 2020년 1월 29일
My problem is the following:
With this first script I'm changing from edf to .mat files, here there's no problem
[hdr,record] = edfread(muestra);
"muestra" is an edf file that changes every loop, so my purpose is not overwite the record variable, but having record_1,record_2... for each "muestra". For that I've done the following:
matFileName = fullfile(pwd, sprintf('angry_%3d%3d.mat',trial,experimento));
save(matFileName, 'record');
The problem that I'm facing with is that even I save them with different names, once I try to load all of those into the workspace they still have the same name "record" as you can be seen in the screenshoot, I don't know how to avoid that name and have the one I've said before.

채택된 답변

Mohammad Sami
Mohammad Sami 2020년 1월 29일
[hdr,record] = edfread(muestra);
recordname = sprintf('record_%i',trial);
matFileName = matfile(fullfile(pwd, sprintf('angry_%3d%3d.mat',trial,experimento)),'Writable',true);
matFileName.(recordname) = record;
clear matFileName;
  댓글 수: 3
Mohammad Sami
Mohammad Sami 2020년 1월 29일
편집: Mohammad Sami 2020년 1월 29일
I used the trial variable. if it does not get incremented use another variable.
record_num = 1;
[hdr,record] = edfread(muestra);
recordname = sprintf('record_%i',record_num); % create the variable name e.g record_1
matFileName = matfile(fullfile(pwd, sprintf('angry_%3d%3d.mat',trial,experimento)),'Writable',true);
matFileName.(recordname) = record;
record_num = record_num + 1; % increment id
clear matFileName;
%% second read
[hdr,record] = edfread(muestra);
recordname = sprintf('record_%i',record_num);
matFileName = matfile(fullfile(pwd, sprintf('angry_%3d%3d.mat',trial,experimento)),'Writable',true);
matFileName.(recordname) = record;
record_num = record_num + 1; % increment id
clear matFileName;
Eva Maria Deltor Cortés
Eva Maria Deltor Cortés 2020년 1월 29일
Thanks!!! Without your help I wouldn't have been able to continue!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 EEG/MEG/ECoG에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by