basics - a more compact way to do this...?

1 visualización (últimos 30 días)
Neuron
Neuron el 14 de Nov. de 2011
I have a size(x) function that gives answer: 1 23 (x is a vector with 23 points). I can take the second value like this
k=size(x)
k(2)
Is there a more immediate way to do this? in a single command, something like.. size(x)(2) ?

Respuesta aceptada

Sven
Sven el 14 de Nov. de 2011
The simplest method is:
k = size(x, 2)
The second argument of the "size" method is the dimension in which to query - in your case the 2nd dimension
  1 comentario
Fangjun Jiang
Fangjun Jiang el 14 de Nov. de 2011
Sometimes you can use length() or numel().

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by