0

Suppose we have directory containing structured data files (text files containing matrix of numbers only).

Is it possible to load them all, no matter what filename they have, into cell array of matrices?

1 Answer 1

1

use dir to get all the files in a directory:

fls = dir( fullfile( myFolder, '*.txt' ) );
n = numel(fls);
data = cell(1,n); % preallocate
fot ii=1:n
    data{ii} = dlmread( fullfile( myFolder, fls(ii).name ) ); % read the file using importdata/dlmread/load - whatever works for you
end
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot, this saves a lot of time. When loading form same directory, use myFolder='.';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.