I have a peculiar frustrating situation: am trying to set the headers of a 1×19 table from an excel table to provide as an input to a Machine learning struct. As per the documentation of the struct i need to provide a MATLAB Table with 19 rows of numeric data with the following headers.
gender seniorcitizen partner dependents tenure phoneservice multiplelines internetservice onlinesecurity onlinebackup deviceprotection techsupport streamingtv streamingmovies contract paperlessbilling paymentmethod monthlycharges totalcharges10 0 200 200 16 100 200 200 300 300 300 300 300 300 502 200 630 18.95 326.8
However, the problem is, for some reason, i get the dreaded, unintelligible error message:
Function 'subsindex' is not defined for values of class 'table'.
1. I tried importing the excel as a variable using the import facility. Does not work. 2. I tried creating the table from a cell array of headers using the cell2table. That gives another of the infamous cryptic errors. (seriously, wonder who writes those error messages in MATLAB? they seem to have a special training for making it as unfriendly as possible)
I found that the Properties of the table in MATLAB workspace look like below:
description: '' userdata: [] dimensionnames: {'row' 'variables'} variablenames: {1×19 cell} variabledescriptions: {} variableunits: {} rownames: {}
I need to set the VariableNames directly as values instead of a 1×19 cell. How do i do it? (And pls avoid referring me to MATLAB table documentation. Does not work)
Best Answer