Update the number of columns needed for my times table

조회 수: 7 (최근 30일)
Norma
Norma 2024년 9월 12일
댓글: Star Strider 2024년 9월 12일
Hello, when I convert my csv file to a timestable, it's saying there are 67 columns when there should be 65 columns. I want to update the Variable Names and its not allowing me to edit the headers in the table without editing all the variables. When I attempt it, i get this error: "Conversion to cell from char is not possible." How do I count the number of columns in a timestable to then be able to delete the excess columns left over at the end of the table so that I can update the variableNames? I'm still fairly new to MATLAB and dealing with an older version so I'm having trouble with this.
  댓글 수: 1
Stephen23
Stephen23 2024년 9월 12일
"How do I count the number of columns in a timestable to then be able to delete the excess columns left over at the end of the table so that I can update the variableNames?"
I doubt that you need to count them:
N = 5; % number of required columns
T = array2table(randi(9,4,7)) % extra columns
T = 4x7 table
Var1 Var2 Var3 Var4 Var5 Var6 Var7 ____ ____ ____ ____ ____ ____ ____ 5 4 8 3 6 9 9 1 1 6 4 9 5 8 3 5 4 6 7 4 2 7 4 1 9 8 7 7
T(:,N+1:end) = []
T = 4x5 table
Var1 Var2 Var3 Var4 Var5 ____ ____ ____ ____ ____ 5 4 8 3 6 1 1 6 4 9 3 5 4 6 7 7 4 1 9 8
Note that you might lose data.

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2024년 9월 12일
It would heelp to have your .csv file and a description of what you want to do. Also, it might be easiier to do this in a table and then use table2timetable to convert it to a timetable.
If you only want to edit one variable name, that is straightforward —
T1 = array2table(randi(50,5))
T1 = 5x5 table
Var1 Var2 Var3 Var4 Var5 ____ ____ ____ ____ ____ 21 40 39 48 40 36 3 44 24 25 4 14 23 26 23 19 26 2 30 37 46 20 14 42 9
T1.Properties.VariableNames{3} = 'Column 3'
T1 = 5x5 table
Var1 Var2 Column 3 Var4 Var5 ____ ____ ________ ____ ____ 21 40 39 48 40 36 3 44 24 25 4 14 23 26 23 19 26 2 30 37 46 20 14 42 9
Just choose the one you want to change.
.
  댓글 수: 2
Norma
Norma 2024년 9월 12일
Hello, thank you so much! I was using parentheses instead of curly braces.
Star Strider
Star Strider 2024년 9월 12일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numeric Types에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by