For Looping to import .mat files

조회 수: 1 (최근 30일)
Jake Bowd
Jake Bowd 2020년 1월 23일
댓글: Stephen23 2020년 1월 23일
Hi All,
I have a folder that I want to import all .mat files in from. So far I have got the following which identifies the amount of .mat files there are, however I am unsure how to import the .mat data in after this.
cd('D:\Leuven_Visit\Workflow\Matlab\Results\HV_NL');
procfiles=dir('*.mat');
nparticipants=size(procfiles,1);
for i=1:nparticipants
end

채택된 답변

Bhaskar R
Bhaskar R 2020년 1월 23일
편집: Bhaskar R 2020년 1월 23일
procfiles = dir('D:\Leuven_Visit\Workflow\Matlab\Results\HV_NL\*.mat');% cd is not recommended
for iMat= 1:size(procfiles, 1)
load(fullfile(procfiles(iMat).folder, procfiles(iMat).name));
end
  댓글 수: 1
Stephen23
Stephen23 2020년 1월 23일
Even better to load into an output variable (which is a scalar structure):
S = load(...)

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

추가 답변 (0개)

카테고리

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