How to store and print comments from a script

조회 수: 5 (최근 30일)
james
james 2012년 4월 9일
I have an .m file that looks like this:
%Information
%Information
%Information
C = [1 1 0 0 0;
1 0 1 0 1;
I am trying to get the information from the header and print it later in my script. So I'm calling the m file to get the variables, but don't know how to get the comments to print later. I know typing help (name of script) will make it appear, I just don't know how to store it. Anyone?

채택된 답변

Jarrod Rivituso
Jarrod Rivituso 2012년 4월 9일
Hmm...
helpText = help('yourMATLABFileName')
Also, you may then want to split each line into a separate string
lineByLine = regexp(helpText,char(10),'split')
If you want more than the help text, check out the fileread function
doc fileread

추가 답변 (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