Extract *.mat-Variables with same names from different directories
Show older comments
Hello,
before I even start an attempt to put my problems into words, take a loot at the attached screencap. It does a fine job of explaining the entire structure.
There are 96 of these directories in their parent folder 'J', all 96 of which are structurally named. However, I need to access the variable 'J' that lies within 'J.mat' in each of them.
I have an idea of iterating recursively through the folders (that's how I got them in the first place), but I am lost at the MATLAB code of loading them into the workspace. A simple 'load' command will give me a strut, which I can't do much with.
Ideally, I'd like a workspace containing all 96 variables structurally named, like 'J_333_01_a'. From there, I should be able to process them further (plotting etc). Thus far, I created arrays to function as a source for a potential for-loop:
arrX=[333,343,353,363]; arrY=[0.025,0.05,0.1,0.2]; arrZ=['a','b','c','d','e','f']
I am stuck at actually translating my pseudo kind-of-bash-code into compatible MATLAB code:
x=[333,343,353,363];
y=[0.025,0.05,0.1,0.2];
z=['a','b','c','d','e','f'];
for xelement in x; do
for yelement in y; do
for zelement in z; do
A=load('./xelement_yelement_zelement/J.mat');
B=struct2cell(A);
J_xelement_yelement_zelement=cell2mat(B)
The end goal is to compare the J values and draw conclusions about the influence of the parameters x, y and z. So converting from struts may not be ideal to reach that goal, but I am a complete noob so feel free to rectify.
Thank you!
Accepted Answer
More Answers (0)
Categories
Find more on File Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!