问题描述
我想搜索以前使用的特定命令.是否可以在MATLAB命令历史记录上进行自由文本搜索?
I would like to search for a specific command I've previously used. Is it possible to do a free text search on MATLAB command history?
推荐答案
如果要以编程和平台独立的方式完成此任务,可以先使用,用于以字符数组的形式获取命令历史记录:
If you want to accomplish this in a programmatic and platform-independent manner, you can first use MATLAB's Java internals to get the command history as a character array:
history = com.mathworks.mlservices.MLCommandHistoryServices.getSessionHistory;
historyText = char(history);
然后,您可以使用 STRFIND 或 REGEXP .您还可以使用 CELLSTR ,因为有时可以更轻松地使用它们.
Then you can search through the character array however you like, using functions like STRFIND or REGEXP. You can also turn the character array into a cell array of strings (one line per cell) with the function CELLSTR, since they can sometimes be easier to work with.
这篇关于如何搜索MATLAB命令历史记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!