How to get a list of the structures used in a matlab code?

조회 수: 15 (최근 30일)
Robert Jones
Robert Jones 2018년 6월 4일
댓글: Jan 2018년 6월 4일
I need to get familiar with a large MATLAB code somebody else created. I would like to create a list of all the structures for documentation purposes. Any ideas?
Thanks
  댓글 수: 1
Walter Roberson
Walter Roberson 2018년 6월 4일
This can be a bit difficult to define. Technically, MATLAB considers each different struct to be a different data type. For some purposes, two structs are considered to be compatible if they have the same field names; for other purposes two structs are considered to be compatible only if they have all the same field names in the same order.

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

채택된 답변

Jan
Jan 2018년 6월 4일
If you got a "large code" (maybe some 100'000 lines of code) and it is not well documented, you are in pain. Such "brownfield projects" are extremely hard to debug, because you have to guess the purpose of the code. Therefore it is usually more efficient to delete the code and rewrite it.
But let's assume that this is not an option. Then getting a list of structs can be done only by reading the source code and collect, where which struct is defined and how. There is no magic tool to do this. Maybe the debugger helps you: Set a breakpoint at the end of each function and get the contents of the currently existing structs:
S = whos;
S = S(strcmp({S.class}, 'struct'));
disp(S)
  댓글 수: 2
Jan
Jan 2018년 6월 4일
[MOVED from section for answers] Robert Jones wrote:
Thanks, but all I wanted is the list of the names of the objects shown in the workspace. Isn't a simple way to get this?
Jan
Jan 2018년 6월 4일
@Robert: Please post comments in the section for comments to avoid unnecessary confusion. Thanks.
Uhm. Yes. Use the code I've posted.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

제품


릴리스

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by