Loading multiple mat files with the same name from folder source

I would like to be able to load a mat file named 'Synergy' from a folder path, in this folder path there are multiple participants (which can vary) which have been separated into their participant number but all contain the 'Synergy.mat' file
For example the top folder path is : N:\Gait\Research\Current Projects\CP Hemi Synergy Analysis\Data test participants
participant 1's data is located here : N:\Gait\Research\Current Projects\CP Hemi Synergy Analysis\Data test participants\CP_Syn01
Similarly, Participant 2 here: N:\Gait\Research\Current Projects\CP Hemi Synergy Analysis\Data test participants\CP_Syn02
I would like this automated to call in the Synergy mat file for any number of participants located in this folder.
Please help

 채택된 답변

Image Analyst
Image Analyst 2018년 1월 15일

0 개 추천

See recursive file listing demo (attached) in my function, that works for old versions of MATLAB.

추가 답변 (1개)

Greg
Greg 2018년 1월 15일
The (relatively) new recursive dir is amazing.
mats = dir('N:\Gait\Research\Current Projects\CP Hemi Synergy Analysis\Data test participants\**\Synergy.mat');

댓글 수: 5

Thanks. Can you please help me implement this into my code. Currently, if I copy and paste this straight in it returns a 0x1 structure, presumably due to an error on my behalf.
What release of MATLAB are you running?
Greg
Greg 2018년 1월 15일
편집: Greg 2018년 1월 15일
Ahh, that's the relatively new part. Can only use dir recursively in R2016b+.
Your next best option is use a Windows system dir call, or download a recursive dir from file exchange.

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

카테고리

도움말 센터File Exchange에서 File Operations에 대해 자세히 알아보기

태그

질문:

2018년 1월 15일

답변:

2018년 1월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by