How to set names to column vectors?

Hi my friends, how to set name to columns vectors?, for instance these? disp(C) 15.5528 601.4385 11.8749 129.4530 13.2851 270.5859 9.9169 3.4992 20.6769 936.8461 12.1105 436.2808 16.3999 768.1774

 Respuesta aceptada

George
George el 10 de Oct. de 2016

1 voto

If you want to associate a variable name with a piece of data I think your best bet is to use a table instead.
If you just want to display formatted text you can use sprintf().

4 comentarios

George how would i put the name to the two columns of my matrix?, the first column (Temp), and second one (Irr):
12.1105 436.2808
11.8749 129.4530
9.9169 3.4992
16.3999 768.1774
13.2851 270.5859
20.6769 936.8461
15.5528 601.4385
George
George el 10 de Oct. de 2016
Assuming that matrix is called myMatrix
A = table(myMatrix, 'VariableNames', {'Temp', 'Irr'});
will create a table variable of the matrix and name the variables Temp and Irr.
Guillaume
Guillaume el 10 de Oct. de 2016
Editada: Guillaume el 10 de Oct. de 2016
The correct syntax to convert a matrix into a table is:
A = array2table(myMatrix, 'VariableNames', {'Temp', 'Irr'});
The table constructor expects one input per column, not a matrix of columns. The above will result in an error.
George
George el 10 de Oct. de 2016
Oops, that's correct. Good catch. I was recalling that he had said column vectors.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Productos

Preguntada:

el 10 de Oct. de 2016

Comentada:

el 10 de Oct. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by