How can I instruct MATLAB editor to open a file with focus on specific line/function?

조회 수: 2 (최근 30일)
Hi,
I have a MATLAB class file in which i have implemented several methods. I am developing a UI around this using GUIDE and in the UI I would like the user to click on a particular method's name. Then Editor should open up the class and instead of having the 1'st line onwards in the view, the user should see the code from the test method onwards.
Is anyone aware of a way to achieve this? If so please share it.
The alternatives fread,fseek may work but a way to do this in the editor is what I am looking for.
Thanks!

채택된 답변

Sean de Wolski
Sean de Wolski 2014년 9월 5일
This can be done using the editor api.
edit your_class.m
hEditor = matlab.desktop.editor.getActive;
hEditor.goToLine(line_number)
  댓글 수: 3
Joseph Cheng
Joseph Cheng 2014년 9월 5일
편집: Joseph Cheng 2014년 9월 5일
also you can do.
matlab.desktop.editor.openAndGoToLine('fullpath and filename',linenumber)
for a single line.
oh and to go to specific function (without having to keep track of line numbers
matlab.desktop.editor.openAndGoToFunction('full path and file name','function name')
Balaji
Balaji 2014년 9월 5일
Thank you very much for the info Joseph. That's very helpful.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by