Borrar filtros
Borrar filtros

add index to matrix's rows

1 visualización (últimos 30 días)
Maryam Hamrahi
Maryam Hamrahi el 1 de Jun. de 2016
Comentada: Maryam Hamrahi el 1 de Jun. de 2016
I have a matrix like below:
A= [1 2 4
3 4 2
2 4 5]
With n rows and three columns. I would like to create the following
1: 1 2 4
1: 3 4 2
1: 2 4 5
Thank you all in advance.
  2 comentarios
the cyclist
the cyclist el 1 de Jun. de 2016
Can you be more specific about what you mean by "I would like to create the following"? For example, do you want to
  • display those strings to the command window?
  • create or display a cell array with text and numeric entries?
Please give us more detail.
Maryam Hamrahi
Maryam Hamrahi el 1 de Jun. de 2016
I would like to print the data like below:
I think it would be better if I do it with fprintf
what is your suggestion?
1: 1 2 4
1: 3 4 2
1: 2 4 5

Iniciar sesión para comentar.

Respuesta aceptada

the cyclist
the cyclist el 1 de Jun. de 2016
Editada: the cyclist el 1 de Jun. de 2016
Here's one way:
fprintf('1: %d %d %d\n',A')
For more complicated examples, you might want to read about the formatSpec in the documentation for fprintf.
  1 comentario
Maryam Hamrahi
Maryam Hamrahi el 1 de Jun. de 2016
Thank you very much for the help.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Cell 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