What does 'Undefined operator '*' for input arguments of type 'table'' mean?
3 views (last 30 days)
Show older comments
I have defined all the values to the following equation
ViNew(t,k) = (alpha)*(ViOld)*(t - 1)+(1 - alpha)*Qi(t)
and have asked Matlab to solve it as part of a function for loop. I have defined k as 1:length(1:80), which is the length of the excel sheet where I want my answers placed. Every part of the function is running except for the equation. It says that there is an
Undefined operator '*' for input arguments of type 'table''
I have no idea what that means and how I can fix it. Any guesses?
1 Comment
Adam
on 13 Mar 2016
It means you are trying to multiply a table object by something and table object does not have a '*' multiplication operator defined. Can't really say more than that as you haven't shown any code. I don't use tables, but usually you would have to use some method to operate on each value of a column or row of a table rather than trying to just multiply the table object itself.
Answers (1)
Walter Roberson
on 13 Mar 2016
I suspect you are using readtable() to read a .xls or .xlsx file, thinking that it will return a numeric vector . It will not do so: readtable() returns object-oriented objects of type "table". You cannot multiply a "table" by something.
If this is what is happening, you can either use xlsread() to read into numeric array, or you can use the table indexing operators to extract numeric values from the table; see http://www.mathworks.com/help/matlab/matlab_prog/access-data-in-a-table.html
2 Comments
See Also
Categories
Find more on Tables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!