How do I get values of a certain parameter in a multi-dimensional matrix?

2 visualizaciones (últimos 30 días)
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?

Respuesta aceptada

Stephen23
Stephen23 el 30 de Nov. de 2021
a(~Ind) = NaN

Más respuestas (1)

Matt J
Matt J el 30 de Nov. de 2021
b should be an Nx1 vector where N is the number of elements satisfying A<10000.
  6 comentarios
Leon
Leon el 30 de Nov. de 2021
Many thanks! That works equally well.
Steven Lord
Steven Lord el 30 de Nov. de 2021
You could also use standardizeMissing.
M = 9e26;
format shortg
A = [4 8 M 15 M M; 16 23 42 M M M]
A = 2×6
1.0e+00 * 4 8 9e+26 15 9e+26 9e+26 16 23 42 9e+26 9e+26 9e+26
B = standardizeMissing(A, M)
B = 2×6
4 8 NaN 15 NaN NaN 16 23 42 NaN NaN NaN

Iniciar sesión para comentar.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by