MATLAB: Set the values to nan arrayMATLABnan tb1=[1 2 3 ; 4 5 6 ; 7 8 9]; A1=[0 0 1;1 1 1;0 1 1]; I need to create a new array B1=[nan nan 3;4 5 6;nan 8 9] when A1=0, then B1 should be nan otherwise it should take the values in tb1. Best Answer >> B1 = tb1;>> B1(A1==0) = NaN; Related SolutionsMATLAB: Count number of values between NaN In = [NaN; NaN; NaN; NaN; 1; 1; 1; 1; NaN; NaN; NaN; 1; NaN; NaN; NaN; NaN; NaN; NaN; NaN; 1; NaN; NaN; NaN; NaN];[a,b] = rude(~isnan(In));a(b)rude is on the FEX MATLAB: How to select or group sections of an array without using indexing >> A = [NaN, NaN, NaN, NaN, 2, 3, 6, 7, NaN, NaN, NaN, NaN, NaN, 4, 6, 8, 8, NaN, NaN, NaN, NaN];>> X = diff([true,isnan(A),true]);>> B = find(X<0);>> E = find(X>0)-1;>> F = @(b,e) A(b:e);>> C = arrayfun(F,B,E,'uni',0);>> C{1}ans = 2 3 6 7>> C{2}ans = 4 6 8 8 Related QuestionCorrelation between two row matricesReturning peak values from a column
Best Answer