parfor error with 3D matrix
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
sunny kant
am 30 Jan. 2022
Kommentiert: Matt J
am 31 Jan. 2022
Hello everyone,
I am using the parfor loop for the 3D matrix. When I am executing my parfor loop and getting this error "Error: The variable TEST1 in a parfor cannot be classified. See Parallel for Loops in MATLAB, "Overview". I am replacing the zero value with nan in the loop. Any suggestion regarding this. Your help in this regard will be highly appreciated.
data = rand (20,10,10);
data1 = rand (20,10,10);
parfor ii=1:20
ii
for jj=1:10
jj
TEST1 (ii,jj,:) = data(ii,jj,:).*data1 (ii,jj,:);
TEST1 (TEST1==0) = nan;
end
end
0 Kommentare
Akzeptierte Antwort
Matt J
am 30 Jan. 2022
Move that line outside the loop.
parfor ii=1:20
ii
for jj=1:10
jj
TEST1 (ii,jj,:) = data(ii,jj,:).*data1 (ii,jj,:);
end
end
TEST1 (TEST1==0) = nan;
0 Kommentare
Weitere Antworten (1)
sunny kant
am 31 Jan. 2022
3 Kommentare
Matt J
am 31 Jan. 2022
Thanks Walter for explaining me why my code is not working. As you suggested, I appllied for my code, and now it is working. Thanks for your suggestion on my code and clearing my doubts.
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!