How do I get values of a certain parameter in a multi-dimensional matrix?
이전 댓글 표시
A is a variable with the size of 1000 x 500.
% Index of those that are less than 10000
Ind = A < 10000;
Why does the below give me a 500000 x 1 column data, instead of a 1000 x 500 matrix?
b = a(Ind);
What did I do wrong? How do I get the correct b with the size of 1000 x 500?
채택된 답변
추가 답변 (1개)
Matt J
2021년 11월 30일
0 개 추천
b should be an Nx1 vector where N is the number of elements satisfying A<10000.
댓글 수: 6
Leon
2021년 11월 30일
Matt J
2021년 11월 30일
I think you need to describe better why you expect b to be a 1000x500 matrix. What if there had been only 3 elements for which A<10000?
Leon
2021년 11월 30일
A(A>=10000)=nan;
Leon
2021년 11월 30일
You could also use standardizeMissing.
M = 9e26;
format shortg
A = [4 8 M 15 M M; 16 23 42 M M M]
B = standardizeMissing(A, M)
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!