MATLAB: Trying to use logical matrix to get remove some elements from matrix instead of getting a same matrix im getting a column matrix

logical operations on matrix

a=[1,2,3;12,21,2;2,1,2]
b=(a>1)
c=a(b)
im getting result
b =
0 1 1
1 1 1
1 0 1
c =
12
2
2
21
3
2
2
>> i want c matrix to be 3*3 matrix but im getting it as column matrix

Best Answer

  • Try this:
    a=[1,2,3;12,21,2;2,1,2]
    c = a .* double(a > 1)