56 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Julia Williams am 20 Jun. 2019
Kommentiert: Star Strider am 20 Jun. 2019
Akzeptierte Antwort: 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 Kommentare -2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden
-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden
Melden Sie sich an, um zu kommentieren.
Melden Sie sich an, um diese Frage zu beantworten.
Akzeptierte Antwort
Star Strider am 20 Jun. 2019
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 Kommentare 2 ältere Kommentare anzeigen2 ältere Kommentare ausblenden
2 ältere Kommentare anzeigen2 ältere Kommentare ausblenden
Julia Williams am 20 Jun. 2019
Direkter Link zu diesem Kommentar
https://de.mathworks.com/matlabcentral/answers/468154-how-to-name-columns-in-a-table#comment_716761
Bearbeitet: Julia Williams am 20 Jun. 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 am 20 Jun. 2019
Direkter Link zu diesem Kommentar
https://de.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 am 20 Jun. 2019
Direkter Link zu diesem Kommentar
https://de.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 am 20 Jun. 2019
Direkter Link zu diesem Kommentar
https://de.mathworks.com/matlabcentral/answers/468154-how-to-name-columns-in-a-table#comment_716767
As always, my pleasure!
Melden Sie sich an, um zu kommentieren.
Weitere Antworten (0)
Melden Sie sich an, um diese Frage zu beantworten.
Siehe auch
Kategorien
MATLABGraphicsGraphics ObjectsInteractive Control and Callbacks
Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange
Tags
- columns
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Es ist ein Fehler aufgetreten
Da Änderungen an der Seite vorgenommen wurden, kann diese Aktion nicht abgeschlossen werden. Laden Sie die Seite neu, um sie im aktualisierten Zustand anzuzeigen.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
Amerika
- 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)
Asien-Pazifik
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)
Kontakt zu Ihrer lokalen Niederlassung