Programmatically "Find" and "Select"
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello all,
I wish to programmatically find and select a portion of text in the Editor Window, given the portion of text. Something like the "Find and Replace" command does, but I would like to have this programmatically and not using the Ctrl+F window. Is this possible using MATLAB?
Thanks for all help!
Gabriel
댓글 수: 0
답변 (2개)
Steven Lord
2015년 8월 13일
Use the Editor API to get a handle to the document in the Editor. See "help matlab.desktop.editor" for more information about this API. Use the string processing functions in MATLAB to modify the contents of the Text property of the document object to modify the document.
>> edit bench.dat
>> document = matlab.desktop.editor.getActive;
>> T = document.Text;
>> T(1:6)
ans =
MATLAB
>> T(1:6) = 'Steven';
>> document.Text = T;
댓글 수: 0
Jan
2015년 8월 14일
The FEX submission http://www.mathworks.com/matlabcentral/fileexchange/38264-find-and-replace-in-selection should contain the required details. See also http://undocumentedmatlab.com/blog/accessing-the-matlab-editor
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!