Subtraction Operation Within Cell Array

7 vues (au cours des 30 derniers jours)
itend
itend le 23 Août 2017
Commenté : itend le 24 Août 2017
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 commentaires
Jan
Jan le 23 Août 2017
If only the 3 last lines concern the problem, the rest of the code is confusing only.
itend
itend le 24 Août 2017
Duly noted.

Connectez-vous pour commenter.

Réponse acceptée

Jan
Jan le 23 Août 2017
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 commentaire
itend
itend le 24 Août 2017
Thank you for your help!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by