Как показать локальную документацию Matlab в системном браузере при нажатии клавиши F1?

407
zhangxaochen

Я использую Windows7 и Matlab R2013a на моем ПК. Я считаю, что невозможно скопировать / вставить в окно справки или справки браузера Matlab : enter image description here enter image description here

поэтому я нажимаю « Получить адрес страницы» и копирую команду: web([docroot '/matlab/ref/plot.html'])и добавляю arg, '-browser'чтобы показать локальный файл документа в моем системном браузере:

>> web([docroot '/matlab/ref/plot.html'], '-browser') 

но это довольно хлопотно! Так есть ли способ удобно показать локальный файл документации в моем системном браузере, когда я нажимаю F1? Спасибо заранее;)

0

1 ответ на вопрос

1
Fringe

I have struggled with this question and I think I may have found what you're looking for. You can achieve the following by creating a shortcut at MATLAB and coding there. Label it with the name you desire and then you can run it by simply clicking on it.

Regarding the code, I must say that I used unconventional strategies but very efficient ones and I've only tested it in Windows, but you could do it Unix systems too, by changing the specific implementation.

  1. Prompt the user to input the desired documentation:

    helpdoc=input('Input the doc file: ','s');

Then run a system command (DIR) to find the .html file that Matlab documentation uses. Since the default documentation directory is available from docroot function, one can get the string that must be passed to system function in Matlab, by concatening the dir command as follows:

DirCmd=['dir /s /b "',docroot,'\',helpdoc,'html']; 

The options /s /b are used for looking for the .html file in all subdirectories of docroot and showing up the bare content (fullpath of file). You can get more information in here: https://isc.sans.edu/diary/Finding+Files+and+Counting+Lines+at+the+Windows+Command+Prompt/2244

[Status,CmdOut]=system(DirCmd); 

The system command output issued is assigned to a character array. For multiples matches, one must filter that array and separate into individual paths. For that purpose one can use REGEXP function with the splitting option.

Paths=regexp(CmdOut,'.html','split') 

This will return a cell array with numel=numel(strings)+1 (an extra cell is presented with null content) without the spliting term. So now me must concatenate it with the spliting term and open it in the system browser.

for ii=1:numel(Paths)-1; DocWeb=[Paths,'.html']; web(DocWeb,'-browser'); end

I have tested this looking for doc in documentation and it took 0.7266 sec in my QuadCore 16Gb RAM computer to display the two webpages in my system browser (Chrome), regarding doc and doc for symbolic math toolbox.

I hope this helps, Kudos.

Похожие вопросы