Borrar filtros
Borrar filtros

How to trim two vectors of differing lengths

6 visualizaciones (últimos 30 días)
Todd Simon
Todd Simon el 18 de Ag. de 2016
Comentada: Todd Simon el 18 de Ag. de 2016
If I have two vectors of varying lengths or rows, how do I trim the end of the larger vector so that both vectors are now of the same length? For example, if I have the below:
A = [0
1
2]
B = [0
1
2
3
4]
What I want is something like:
A = [0
1
2]
B = [0
1
2]
Thanks for the help in advance.

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 18 de Ag. de 2016
n=min(numel(A),numel(B))
A=A(1:n)
B=B(1:n)
  1 comentario
Todd Simon
Todd Simon el 18 de Ag. de 2016
Awesome. Thanks for the quick reply Azzi! Super simple!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by