keep getting error Undefined function or variable 'stack', why?

Hi,
I am using Matlab 2015b with statistics toolbox. But I keep getting Undefined function or variable 'stack', why?
Thanks.

댓글 수: 1

Please post the line of code and the complete error message.

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

 채택된 답변

Jan
Jan 2017년 1월 27일
stack(myTbl, 2:end)
The "end" can be interpreted as index only and then Matlab assumes, that "stack" is an array. When you want to use the stack command, Matlab cannot guess what end is related to. Try:
stack(myTbl, 2:4)
and then find out. how you can express the end as you need it.

추가 답변 (2개)

Steven Lord
Steven Lord 2017년 1월 27일

0 개 추천

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

Thanks! I am using the table object, like this: stack(myTbl, 2:end); But just keep getting that error.
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
Walter Roberson 2017년 1월 27일

0 개 추천

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.

댓글 수: 1

Thanks. I just found something interesting here. I am trying the example here with stack: >> Test1 = [93;57;87;89]; Test2 = [89;77;92;86]; Test3 = [95;62;89;91]; U = table(Test1,Test2,Test3) S = stack(U,1:3) and no problem with this example. But when I type: S = stack(U,1:end) it give me this error: Undefined function or variable 'U'. In my case, if I use stack(myTbl, 2:3), it works. But if I use 2:end, it complains: Undefined function or variable 'stack'.

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

카테고리

도움말 센터File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

제품

태그

아직 태그를 입력하지 않았습니다.

질문:

JFz
2017년 1월 27일

댓글:

JFz
2017년 1월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by