I have a struct.I want convert this struct to matrix. I used the
cell2mat( struct2cell( YourStructure ) )
command and I got that error
Error using class
Not enough input arguments.
My struct name is 'class'. I used this
cell2mat(struct2cell(class)).

댓글 수: 1

Stephen23
Stephen23 2018년 6월 25일
Do NOT use the name class, because this shadows the name of the important inbuilt class function.

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

 채택된 답변

Birdman
Birdman 2018년 4월 10일

0 개 추천

This example perfectly works for me. Are you sure that your class struct is really a struct, or what kind of field does it contain? For instance:
class=struct('a',3);
cell2mat(struct2cell(class))
This one can be converted to mat without any error.

댓글 수: 6

z donyavi
z donyavi 2018년 4월 10일
편집: z donyavi 2018년 4월 10일
I attached one image please check this.
Birdman
Birdman 2018년 4월 10일
Share it as a mat file.
z donyavi
z donyavi 2018년 4월 10일
I attached mat file on this comment.
Walter Roberson
Walter Roberson 2018년 4월 10일
MATLAB is case sensitive. A variable named Class is not the same as a variable named class
Birdman
Birdman 2018년 4월 10일
Ups, yes. Exactly. Be careful about that.
z donyavi
z donyavi 2018년 4월 10일
편집: per isakson 2018년 6월 25일
Yes. I typed Class in the codes.Class is a cell array not a struct I checked it in MATLAB.I want convert Class to matrices in a for loop.like this:
Class{1,1}.Data=Class1
Class{1,2}.Data=Class2
..
Class{1,i}.Data=Classi
Class1,Class2...Classi are matrices.

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

추가 답변 (1개)

Sandra Maria Cherian
Sandra Maria Cherian 2018년 6월 23일

0 개 추천

I am also facing the same problem. The code cell2mat(struct2cell(structure)) is not working for me. It is showing error message.Did you get your code working?

댓글 수: 1

z donyavi
z donyavi 2018년 6월 23일
Make sure the type of data is structured with the command of the class(data name).

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

카테고리

도움말 센터File Exchange에서 Structures에 대해 자세히 알아보기

태그

질문:

2018년 4월 10일

댓글:

2018년 6월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by