필터 지우기
필터 지우기

How to parse m-files (in matlab)?

조회 수: 3 (최근 30일)
Andreas Lobinger
Andreas Lobinger 2020년 6월 5일
댓글: Image Analyst 2020년 6월 6일
We have as part of the tool we develop with matlab an m-file that deals as parameter database.
parameter.A = 11; % rick coefficient
parameter.B = 12.3 % morty number
parameter.C11 = 14;
In some (modern) programming languages it's possible to parse code, so you could check by a program if (in this case) all parameter lines contain a comment (which should document it).
  댓글 수: 2
Walter Roberson
Walter Roberson 2020년 6월 5일
Do you need to deal with character vectors? WIth string objects? With continued lines? With "block comments" ? With implicit continuation because you are in the middle of a [ or { definition ?
... Or is every line certain to be very simple like you show?
If every line is certain to be very simple, regexp() can find lines easily, such as
regexp(S, '^[\n%]+$', 'match', 'lineanchors')
Image Analyst
Image Analyst 2020년 6월 6일
Would any of your lines ever have a % in them that is NOT the start of a comment? Like in a format specifier string inside of a fprintf() for example?

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

답변 (0개)

카테고리

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

태그

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by