Borrar filtros
Borrar filtros

Programming Problem in structure

1 visualización (últimos 30 días)
ar fa
ar fa el 9 de Jun. de 2015
Comentada: ar fa el 9 de Jun. de 2015
I have these below codes:
a(1).x = 3;
a(2).x = 1;
a(3).x = -5;
a(4).x = 2;
b = [0 0];
b = a(1:2).x
======================
output => b = 3
I want variable b be equal to [3 1] but variable b is 3.
(Note: "[b(1) b(2)] = a(1:2).x" is not Suitable Answer for me Because for bigger array this solution is overwhelming)
Please Help me.
Thanks

Respuesta aceptada

per isakson
per isakson el 9 de Jun. de 2015
Try
>> b = [a(1:2).x]
b =
3 1
  1 comentario
ar fa
ar fa el 9 de Jun. de 2015
Excellent per Isakson
Thank you very much.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by