This question is closed. Reopen it to edit or answer.

Index Exceeds Matrix Dimensions - Combining variables from different .mat files into one

1 view (last 30 days)
Hello Again!
(I'm new to using structs and dir's so I apologize for all of the questions lately)
I'm trying to load .mat files from two different directories, and then pull variables from them to save into a new .mat file
Below is my current code:
function organizeData
%%Pull Data from relevant .mat files
eegDir = 'Unprocessed\'
eegData = dir([eegDir,'*.mat'])
for i = 1:numel(eegData)
load (fullfile(eegDir,eegName))
experimentName = a{1};
%%Pull Log Data from relevant .mat files
lDir = 'unprocessedLogs\'
logData = dir([lDir,'*.mat']);
for k = 1:numel(logData)
logName = logData(k).name;
if strcmp(logName, experimentName) == 1
load (fullfile(lDir,logName))
block(1).blue.participantID = r(1:5).blue.participant
block(1).green.participantID= r(1:5).green.participant
block(2).blue.participantID = r(6:10).blue.participant
... more code
save_filename = (logName)
I'm trying to call r(1) - r(5)'s information to load into the new struct. Am I going about this wrong?
Thank you again for all of the continued help!
- Mary

Answers (0)

Community Treasure Hunt

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

Start Hunting!