How to Name Columns in a Table? (2024)

55visualizaciones (últimos 30días)

Mostrar comentarios más antiguos

Julia Williams el 20 de Jun. de 2019

  • Enlazar

    Enlace directo a esta pregunta

    https://la.mathworks.com/matlabcentral/answers/468154-how-to-name-columns-in-a-table

  • Enlazar

    Enlace directo a esta pregunta

    https://la.mathworks.com/matlabcentral/answers/468154-how-to-name-columns-in-a-table

Comentada: Star Strider el 20 de Jun. de 2019

Respuesta aceptada: Star Strider

I would like to change my array (y) to a table. y is 1a 3 x 133 double. I would also like to name the columns of this table with the names listed. I have checked to see if these names work within matlab with the isvarname function and they work fine. I have also counted these variables and there are 133 . I have also tried this with commas inbetween the variables but I get the same error message. I am not sure why this error message is popping up and any help is much appreciated!

Code:

B = array2table(y, 'VariableNames',{'L_palmPosX' 'L_palmPosY' 'L_palmPosZ' 'L_thumb_basePosX' 'L_thumb_basePosY' 'L_thumb_basePosZ' 'L_thumb_knuckle1PosX' 'L_thumb_knuckle1PosY' 'L_thumb_knuckle1PosZ' 'L_thumb_knuckle2PosX' 'L_thumb_knuckle2PosY' 'L_thumb_knuckle2PosZ' 'L_thumb_tipPosX' 'L_thumb_tipPosY' 'L_thumb_tipPosZ' 'L_index_basePosX' 'L_index_basePosY' 'L_index_basePosZ' 'L_index_knuckle1PosX' 'L_index_knuckle1PosY' 'L_index_knuckle1PosZ' 'L_index_knuckle2PosX' 'L_index_knuckle2PosY' 'L_index_knuckle2PosZ' 'L_index_tipPosX' 'L_index_tipPosY' 'L_index_tipPosZ' 'L_middle_basePosX' 'L_middle_basePosY' 'L_middle_basePosZ' 'L_middle_knuckle1PosX' 'L_middle_knuckle1PosY' 'L_middle_knuckle1PosZ' 'L_middle_knuckle2PosX' 'L_middle_knuckle2PosY' 'L_middle_knuckle2PosZ' 'L_middle_tipPosX' 'L_middle_tipPosY' 'L_middle_tipPosZ' 'L_ring_basePosX' 'L_ring_basePosY' 'L_ring_basePosZ' 'L_ring_knuckle1PosX' 'L_ring_knuckle1PosY' 'L_ring_knuckle1PosZ' 'L_ring_knuckle2PosX' 'L_ring_tipPosX' 'L_ring_tipPosY' 'L_ring_tipPosZ' ' L_pinky_basePosX' 'L_pinky_basePosY' 'L_pinky_basePosZ' 'L_pinky_knuckle1PosX' 'L_pinky_knuckle1PosY' 'L_pinky_knuckle1PosZ' 'L_pinky_knuckle2PosX' 'L_pinky_knuckle2PosY' 'L_pinky_knuckle2PosZ' 'L_pinky_tipPosX' 'L_pinky_tipPosY' 'L_pinky_tipPosZ' 'R_elbowPosX' 'R_elbowPosY' 'R_elbowPosZ' 'R_wristPosX' 'R_wristPosY' 'R_wristPosZ' 'R_palmPosX' 'R_palmPosY' 'R_palmPosZ' 'R_thumb_basePosX' 'R_thumb_basePosY' 'R_thumb_basePosZ' 'R_thumb_knuckle1PosX' 'R_thumb_knuckle1PosY' 'R_thumb_knuckle1PosZ' 'R_thumb_knuckle2PosX' 'R_thumb_knuckle2PosY' 'R_thumb_knuckle2PosZ' 'R_thumb_tipPosX' 'R_thumb_tipPosY' 'R_thumb_tipPosZ' 'R_index_basePosX' 'R_index_basePosY' 'R_index_basePosZ' 'R_index_knuckle1PosX' 'R_index_knuckle1PosY' 'R_index_knuckle1PosZ' 'R_index_knuckle2PosX' 'R_index_knuckle2PosY' 'R_index_knuckle2PosZ' 'R_index_tipPosX' 'R_index_tipPosY' 'R_index_tipPosZ' 'R_middle_basePosX' 'R_middle_basePosY' 'R_middle_basePosZ' 'R_middle_knuckle1PosX' 'R_middle_knuckle1PosY' 'R_middle_knuckle1PosZ' 'R_middle_knuckle2PosX' 'R_middle_knuckle2PosY' 'R_middle_knuckle2PosZ' 'R_middle_tipPosX' 'R_middle_tipPosY' 'R_middle_tipPosZ' 'R_ring_basePosX' 'R_ring_basePosY' 'R_ring_basePosZ' 'R_ring_knuckle1PosX' 'R_ring_knuckle1PosY' 'R_ring_knuckle1PosZ' 'R_ring_knuckle2PosX' 'R_ring_knuckle2PosY' 'R_ring_knuckle2PosZ' 'R_ring_tipPosX' 'R_ring_tipPosY' 'R_ring_tipPosZ' 'R_pinky_basePosX' 'R_pinky_basePosY' 'R_pinky_basePosZ' 'R_pinky_knuckle1PosX' 'R_pinky_knuckle1PosY' 'R_pinky_knuckle1PosZ' 'R_pinky_knuckle2PosX' 'R_pinky_knuckle2PosY' 'R_pinky_knuckle2PosZ' 'R_pinky_tipPosX' 'R_pinky_tipPosY' 'R_pinky_tipPosZ'});

Error:

The VariableNames property must contain one name for each variable in the table.

0 comentarios

Mostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Iniciar sesión para responder a esta pregunta.

Respuesta aceptada

Star Strider el 20 de Jun. de 2019

  • Enlazar

    Enlace directo a esta respuesta

    https://la.mathworks.com/matlabcentral/answers/468154-how-to-name-columns-in-a-table#answer_380137

  • Enlazar

    Enlace directo a esta respuesta

    https://la.mathworks.com/matlabcentral/answers/468154-how-to-name-columns-in-a-table#answer_380137

That looks like it should work.

Try this:

B = array2table(y)

first, to be sure that all the columns in ‘y’ are actually being assigned to columns in ‘B’. I suspect that they aren’t.

4 comentarios

Mostrar 2 comentarios más antiguosOcultar 2 comentarios más antiguos

Julia Williams el 20 de Jun. de 2019

Enlace directo a este comentario

https://la.mathworks.com/matlabcentral/answers/468154-how-to-name-columns-in-a-table#comment_716761

  • Enlazar

    Enlace directo a este comentario

    https://la.mathworks.com/matlabcentral/answers/468154-how-to-name-columns-in-a-table#comment_716761

Editada: Julia Williams el 20 de Jun. de 2019

That creates the table but it does not name the columns. What do you mean by columns in y aren't being assigned to columns in B? I can see in the table B that each column is named y1, y2, y3, ect. Is this what you mean? Thank you for your help!

Star Strider el 20 de Jun. de 2019

Enlace directo a este comentario

https://la.mathworks.com/matlabcentral/answers/468154-how-to-name-columns-in-a-table#comment_716763

  • Enlazar

    Enlace directo a este comentario

    https://la.mathworks.com/matlabcentral/answers/468154-how-to-name-columns-in-a-table#comment_716763

My pleasure.

I believe that there may be some discrepancy, although now that I imported your entire variable names cell array and let MATLAB count them, it turns out to be a (1x130) cell array, not (1x133).

(I should’ve done that first!)

You need three more variable names, and all should be well.

Julia Williams el 20 de Jun. de 2019

Enlace directo a este comentario

https://la.mathworks.com/matlabcentral/answers/468154-how-to-name-columns-in-a-table#comment_716764

  • Enlazar

    Enlace directo a este comentario

    https://la.mathworks.com/matlabcentral/answers/468154-how-to-name-columns-in-a-table#comment_716764

Amazing! Thank you once again for all your help! My miscount has caused me so much frustration!

Star Strider el 20 de Jun. de 2019

Enlace directo a este comentario

https://la.mathworks.com/matlabcentral/answers/468154-how-to-name-columns-in-a-table#comment_716767

  • Enlazar

    Enlace directo a este comentario

    https://la.mathworks.com/matlabcentral/answers/468154-how-to-name-columns-in-a-table#comment_716767

As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Iniciar sesión para responder a esta pregunta.

Ver también

Categorías

MATLABGraphicsGraphics ObjectsInteractive Control and Callbacks

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Etiquetas

  • columns

Community Treasure Hunt

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

Start Hunting!

Se ha producido un error

No se puede completar la acción debido a los cambios realizados en la página. Vuelva a cargar la página para ver el estado actualizado.


Translated by How to Name Columns in a Table? (7)

How to Name Columns in a Table? (8)

Seleccione un país/idioma

Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .

También puede seleccionar uno de estos países/idiomas:

América

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europa

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom(English)

Asia-Pacífico

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Comuníquese con su oficina local

How to Name Columns in a Table? (2024)
Top Articles
Latest Posts
Article information

Author: Sen. Ignacio Ratke

Last Updated:

Views: 6273

Rating: 4.6 / 5 (56 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Sen. Ignacio Ratke

Birthday: 1999-05-27

Address: Apt. 171 8116 Bailey Via, Roberthaven, GA 58289

Phone: +2585395768220

Job: Lead Liaison

Hobby: Lockpicking, LARPing, Lego building, Lapidary, Macrame, Book restoration, Bodybuilding

Introduction: My name is Sen. Ignacio Ratke, I am a adventurous, zealous, outstanding, agreeable, precious, excited, gifted person who loves writing and wants to share my knowledge and understanding with you.