read a commented line from code

조회 수: 5 (최근 30일)
noa
noa 2013년 7월 11일
hi
i need to scan a large number of files containing interesting data in the comments
at the same line for all files
is there a way i can display that line on the command (it will make it easier to select the relevant files), or any other method is welcome as well
thanks
  댓글 수: 2
Jan
Jan 2013년 7월 11일
Which kind of files and comments are your talking of? Text files, binary files with comments in the resources, etc? Do you mean M-files and you want to read a specified line number? If so, does it matter that the line is a comment? Does "display on the command" mean the command window?
dpb
dpb 2013년 7월 11일
You could write a little script that reads the file(s) and displays the specific line(s) in a text box, say, from which user could scroll and/or copy/paste to command line.
I'm not aware there's a way to actually write to the command window prompt although other than the text box you could forego that and simply use disp() to output the desired text to the screen and then the user can cursor up and select and copy/paste.
The textbox route might be less intrusive as it wouldn't scroll existing stuff of the top of the window...

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

답변 (2개)

per isakson
per isakson 2013년 7월 13일
편집: per isakson 2013년 7월 13일
It is possible to make all kinds of fancy tools. However, how much work are you prepared to invest in the tool?
You want to show the filename together with one comment-line? If so,
  • print to the command window: filename and comment in two columns.
  • add a hyperlink to the filename
  • use cprintf
See
And if you want something more fancy LOOK4 might serve as a starting point

Image Analyst
Image Analyst 2013년 7월 13일
Why not just use fgetl() to read in lines until you get to "the same line" (say, line #5 or whatever)? Then call fprintf() to spit that line out to the command window. Or use set() to send that line to a static text label in your GUI.

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by