Accessing multiple cells from char array

Dear all, I have a problem with the following: in a directory I store 12 *mat files - each of these files store one variable, 'averages'. Each 'averages' is a 1xn cell array of various lengths for different *mat files(i.e. 'averages' for 1.mat is of length 9, and 'averages' for 2.mat is of length 6 etc.). I need to load all of those files from directory and perform a cross-correlation between vectors of the same length that I store in each of the cells of all of 'averages' from different *mat files. I wanted to use this:
Folder = 'C:...'
FileList = dir(fullfile(Folder, '*.mat'));
nFile = numel(FileList);
for i1 = 1:nFile
file1 = fullfile(Folder, FileList(i1).name);
for i2 = i1+1:nFile
file2 = fullfile(Folder, FileList(i2).name);
...
end
end
- but the problem is, I have multiple cells within each of my *mat files and not sure how to operate within the character string arrays.
This is what I do witin one 'averages' file, and I would like to do the same between all of 'averages' *mat files:
corr_out = zeros(length(averages),length(averages));
for m=1:length(all_files);
for p=1:length(averages);
for r=p+1:length(averages);
corr_out(p,r) = xcorr(averages{1,p}(:)',averages{1,r}(:)',0,'coeff');
end
end
end
I am attaching two exemplary 'averages' files. Would be very grateful for your help!

 採用された回答

Stephen23
Stephen23 2018 年 6 月 12 日
編集済み: Stephen23 2018 年 6 月 12 日

1 投票

First just load all of the files, and put the required data into a cell array:
Folder = 'C:...'
FileList = dir(fullfile(Folder, '*.mat'));
nFile = numel(FileList);
cFile = cell(1,nFile);
for k = 1:nFile
F = fullfile(Folder, FileList(k).name);
S = load(F);
cFile{k} = S.averages;
end
and then do your cross correlation on the contents of the cell array cFile.

1 件のコメント

sprklspring
sprklspring 2018 年 6 月 12 日
Thanks Stephen! Much appreciated.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCell Arrays についてさらに検索

質問済み:

2018 年 6 月 12 日

コメント済み:

2018 年 6 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by