Subtraction Operation Within Cell Array

7 ビュー (過去 30 日間)
itend
itend 2017 年 8 月 23 日
コメント済み: itend 2017 年 8 月 24 日
Hello,
I have a 2 x 6 cell array, each cell in row #1 {1 -> 6, 2} contains a 1024 x 1024 x 100 matrix. The first cell in row #2 {2,1} contains a 1024 x 1024 matrix. I want to subtract the cell in {2,1} from each "slice" of each matrix in row#1. I am having trouble putting together code that would do this... here is what I have so far (the bit that this question is referring to is the last 3 lines of code):
%%Get a list of all files in the folder with the desired file name pattern.
filePattern = fullfile(myFolder, '*.spe');
dinfo = dir(filePattern);
filenames = fullfile(myFolder, {dinfo.name});
output = cellfun(@readSPE, filenames, 'uniform', 0); %convert to spe
output = cellfun(@double,output, 'uniform', 0); %convert to double
%%remove first five frames to reduce variability
output = cellfun(@(x)x(:,:,5:end),output,'uni',false);
%%import background
bkg = median(double(readSPE('bkg_10AOC_LightsOff.spe')),3); %temporal median + double
output{2,1} = bkg; %insert into cell array
%%subtract bkg from each cell
for i = 1:length(filenames)
output{1,i} - output{2,1};
end
I am not sure that this is accomplishing what I... any suggestions? If anyone has suggestions on a better methodology please let me know :)
Thank you for your time and help!!
  2 件のコメント
Jan
Jan 2017 年 8 月 23 日
If only the 3 last lines concern the problem, the rest of the code is confusing only.
itend
itend 2017 年 8 月 24 日
Duly noted.

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

採用された回答

Jan
Jan 2017 年 8 月 23 日
Your idea looks fine:
for i = 1:length(filenames)
output{1, i} = output{1,i} - output{2,1};
end
This works since R2016b. For older versions:
output{1, i} = bsxfun(@minus, output{1,i}, output{2,1});
  1 件のコメント
itend
itend 2017 年 8 月 24 日
Thank you for your help!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by