keep getting error Undefined function or variable 'stack', why?
Show older comments
Hi,
I am using Matlab 2015b with statistics toolbox. But I keep getting Undefined function or variable 'stack', why?
Thanks.
1 Comment
Jan
on 27 Jan 2017
Please post the line of code and the complete error message.
Accepted Answer
More Answers (2)
Steven Lord
on 27 Jan 2017
0 votes
You're trying to call the stack method of the dataset class? Are you calling it with a dataset object as the first input? If not, MATLAB won't call the method.
FYI, I recommend that you use the table object that is part of MATLAB (introduced in release R2013b) instead of using the dataset object. I don't know how much functionality we're going to add to dataset going forward, but I know we have added functionality to table above and beyond what's available for dataset in recent releases.
2 Comments
JFz
on 27 Jan 2017
Steven Lord
on 27 Jan 2017
The use of end may be confusing MATLAB into thinking that you're attempting to index into a variable named stack. You should change it to use the width method (or size(myTbl, 2))
stack(myTbl, 2:width(myTbl))
Walter Roberson
on 27 Jan 2017
0 votes
stack() from basic MATLAB is defined for tables and timetables.
stack() from the stats toolbox is defined for dataset arrays.
stack() from the Neural Network toolbox is defined for network objects.
stack() from the Control Systems toolbox expects a numeric first argument and models for the rest of the arguments. For historical implementation reasons it seems plausible to me that it might be callable with numeric arrays or perhaps with structures. It is the only Mathworks stack() call that I can see as potentially being invoked for numeric objects rather than specialized objects.
My suspicion is that you did not pass a dataset or table or timetable to stack() and that you do not have Control Systems installed, so it could not find an appropriate call.
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!