MATLAB Answers

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

조회 수: 1(최근 30일)
AJAY CHANDRA DORAGARI
AJAY CHANDRA DORAGARI 2020년 6월 25일
편집: AJAY CHANDRA DORAGARI 2020년 6월 25일
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

추가 답변(1개)

the cyclist
the cyclist 2020년 6월 25일
편집: the cyclist 2020년 6월 25일
Assuming you want zeros in the other locations:
a=[1,2,3;12,21,2;2,1,2]
b=(a>1)
c = zeros(size(a));
c(b)=a(b)
c =
0 2 3
12 21 2
2 0 2
  댓글 수: 3

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by