Adding each values to row vector

Hi, I just started to study Matlab and quite confused by vectors.
I am trying to assign values to row vector
[a,b,c]=ones(1,3)
I thought 1 will be assigned to a,b, and c. but error occured saying too many output arguments.
Is there a function to assign multiple values to vector at once?
thanks

 Respuesta aceptada

Star Strider
Star Strider el 27 de Mzo. de 2021
One option is the deal function:
[a,b,c] = deal(1,2,3)
producing:
a =
1
b =
2
c =
3
.

2 comentarios

Duckyoon Go
Duckyoon Go el 27 de Mzo. de 2021
Thank you so much. deal function was exaclty the one I was looking for.
Star Strider
Star Strider el 28 de Mzo. de 2021
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (1)

William
William el 27 de Mzo. de 2021
... but if you just want to create a vector with three values, you would use a statement like:
a = [1,2,3];
This produces a vector with three elements:
a(1)=1, a(2)=2 and a(3)=3

1 comentario

Duckyoon Go
Duckyoon Go el 28 de Mzo. de 2021
Thank you sir, even though the answer was not what I was looking for, still appreciate your effort. :)

Iniciar sesión para comentar.

Categorías

Más información sobre Entering Commands en Centro de ayuda y File Exchange.

Productos

Versión

R2019a

Etiquetas

Preguntada:

el 27 de Mzo. de 2021

Comentada:

el 28 de Mzo. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by