Dear All Community members,
I have two 3D matrices, AB1/AB2=1250x441x451 and two arrays, C=1×5 and D=1×1250.
Instead of running loops I want to use a vectorization code to do the following operation;
If D(i)<=C (for each value in C)
ABC(i)=AB1(i)
else
ABC(i)=AB2(i).
As an end-result I want five different 3D matrices ("ABC1", "ABC2"…"ABC5"), one for each value in C.
In order to use vectorization I could repeat the 3D matrices ("AB1" and "AB2") and the 1D array ("D") 5 times using repmat and repeat the 1D array ("C") 1250 times using repelem. But I am not sure how to proceed any further or even if this is the best approach..
How do I apply the logical condition (D<C) to the 3D matrices?
All help is greatly appreciated.
Kind regards
Best Answer