How to slice these variables?
Show older comments
Hi,
can somebody help me to slice these variables in a parfor loop?
indices(:,1) = max(min(ceil(vector(:,1)-Xcoor),nx),1);
indices(:,2) = max(min(ceil(vector(:,2)-Ycoor),ny),1);
indices(:,3) = max(min(ceil(vector(:,3)-Ycoor(idx_parfor)),nz),1);
I currently use the construction:
indices_1 = max(min(ceil(vector(:,1)-Xcoor),nx),1);
indices_2 = max(min(ceil(vector(:,2)-Ycoor),ny),1);
indices_3 = max(min(ceil(vector(:,3)-Ycoor(idx_parfor)),nz),1);
Is there any way to use a single variable indices again? In order to allow for indexing of the variable indices? The parfor variable is of course idx_parfor. An indexed solution would be unavoidable if there are more than 3 indices.
Best Joerg
2 Comments
Rik
on 9 Nov 2021
If it is merely the detection that is preventing execution, you could consider putting this in a separate function.
Also, shouldn't you be using Zcoor in your third call?
Joerg Pfannmoeller
on 14 Mar 2022
Accepted Answer
More Answers (0)
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!