Reputation: 529
I have two matlab arrays, very large, over 41k rows each with 10 columns.
I also have an array of the exact same size filled with 1's and 0's. I need to apply this logic array to the first array and if the value is logic true, pass the number, otherwise if false it must return NaN.
using something like:
output= number(array)
Only gives an output of the positive logic array values but I need to keep the array the same size/structure, how can I do this?
Upvotes: 1
Views: 84
Reputation: 1105
First let us generate a dummy matrix and a dummy mask
A = rand(5,3);
M = randi([0 1], 5, 3);
then you can apply the mask to the original matrix
A(not(M)) = nan;
Upvotes: 2
Reputation: 45752
Pre-allocate output
with NaN
s:
output = NaN(size(number))
output(array) = number(array)
Upvotes: 1