What is causing this, 'Function 'subsindex' is not defined for values of class 'cell'.'?

It worked once before and now it will not give the time of day. Can anyone with this issue?
last = {'Smith';'Jones';'Webb';'Anderson'};
first = {'Fred';'Kathy';'Milton';'Johnn'};
age = [6;22;92;45];
height = [47;66;62;72];
weight = [82;140;110;190];
table(last,first,age,height,weight)
This is the error
Function 'subsindex' is not defined for values of class 'cell'.

 Respuesta aceptada

Jan
Jan el 26 de Feb. de 2017
Editada: Jan el 26 de Feb. de 2017
You have redefined the term "table" as a variable. See:
which table -all
This so called shadowing causes troubles frequently. The solution is easy: Avoid using names of built-in functions as variables. In your case:
tableback = table;
clear('table');
Then your code runs successfully.

5 comentarios

@Daryl Hurwitz: you should accept this answer if it resolves your question.
OH GOD!! THANK YOU!! Had the same problem and it was doing my head in!!
Could you explain how he redefined table? He is just using the table function in the code right? I have a similar issue but with subsindex of string and I have no clue how it works or what is the problem
@Mattijs Mientki: table was redefined like this:
table = ...
It might have been in some code written by the OP, or perhaps in some third-party code that they (unknowingly) called, but the end results is that table ended up being something that was not the inbuilt function.
Use which to check which function/variable/... are mapped to that name:
which table -all

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Preguntada:

el 26 de Feb. de 2017

Editada:

el 21 de Jun. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by