How to iterate over parfor
Show older comments
Hi everyone.
I need to apply some heavy signal processing to a third-order tensor (typcal set of data coming from thermography). The data has the structure of pixel-pixel-time.
I wanto to use the parfor, but I am struggling in implementing a for loop.
I am aware that this syntax does not work:
%% mock data
input signal = zeros(1,3000);
output_raw_signal = zeros(512,640,3000);
AA_filtered = []; %% no need to prealloc I know
parfor i=1:512
for j=1:640
AA_filtered(i,j,:) = xcorr(squeeze(output_raw_signal(i,j,:)),.input_signal) %% cross correlation for each pixel in time
end
end
If I run this, I get the error "The variable in a parfor cannot be classified"
But what is a possible solution?
Greetings.
Luca
1 Comment
Luca Pecoriello
on 10 Dec 2019
Accepted Answer
More Answers (1)
Walter Roberson
on 11 Dec 2019
Edited: Walter Roberson
on 11 Dec 2019
%% mock data
input_signal = zeros(1,3000);
output_raw_signal = zeros(512,640,3000);
AA_filtered = []; %% no need to prealloc I know
parfor i=1:512
output_raw_signal_i = output_raw_signal(i,:,:);
for j=1:640
AA_filtered_i(j,:) = xcorr(output_raw_signal_i(j,:).', input_signal) %% cross correlation for each pixel in time
end
AA_filtered(i, :, :) = AA_filtered_i;
end
2 Comments
Luca Pecoriello
on 11 Dec 2019
Walter Roberson
on 11 Dec 2019
Try removing the initial assignment to AA_filtered
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!