フィルターのクリア

how to obtain the mean for single variable/location of a multiple 3d .mat file ?

1 回表示 (過去 30 日間)
Hanisah noh
Hanisah noh 2020 年 5 月 27 日
コメント済み: Ameer Hamza 2020 年 5 月 28 日
i have 240 files of 3dimension .mat files with 140x122x118
i have obtain the mean of these files using this method (credits to matlab community):
...
files=dir('*.mat');
totalfile = numel(files);
C = cell(1,totalfile);
for a = 1:totalfile
T = load(files(a).name)
C(a) = struct2cell(T);
end
M = cat(4,C{:})
M(isnan(M))=0 % replace NaN to 0
ave = mean(M,4) % mean of the 4th dimension
however,
how do i obtain the mean of a single location/variable from all these 240 files, eg: location{100,10,50} ?
thank you

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 5 月 27 日
Something like this
files=dir('*.mat');
totalfile = numel(files);
V = zeros(1,totalfile);
for a = 1:totalfile
T = load(files(a).name)
C = struct2cell(T);
V(a) = C{1}(100,10,50)
end
V(isnan(V))=0 % replace NaN to 0
ave = mean(V)
  2 件のコメント
Hanisah noh
Hanisah noh 2020 年 5 月 27 日
thank you Ameer Hamza
what does {1} indicates ?
..
V(a) = C{1}(100,10,50)
..
Ameer Hamza
Ameer Hamza 2020 年 5 月 28 日
It is chained indexing in MATLAB. Normally chained indexing is not allowed in MATLAB because parenthesis are used both for functions and indexing. However, for cell arrays, chained indexing is allowed.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with Image Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by