how to resolve this program
조회 수: 2 (최근 30일)
이전 댓글 표시
I have 2 matrix, i.e dataNID(1000x20) and A(1x20). I compare the A with dataNID. ans1 is less than and ans2 is morethan. these 2 matrix (1000x20), I am getting logically. but if I write program for values of particular logic then it is showing all values in a single column. but i need all value in the respective columns. here is the code
ans1= (dataNID < A);
ans2= (dataNID > A);
value1= dataNID(ans1);
value2= dataNID(ans2);
please help me.
댓글 수: 0
채택된 답변
KSSV
2018년 6월 26일
value1 and value2 will be columns only. From the matrix, you are picking those values which obey the condition, by using logical indexing. The output is correct. IF you are expecting a matrix, you can do the following:
A = rand(10) ;
B = rand(1,10) ;
idx0 = A>B ;
idx1 = A<B ;
C = NaN(size(A)) ;
C(idx0) = A(idx0)
The output is a matrix with NaN where condition is not obeyed.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!