이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
m file to instead save button in set path dialog
조회 수: 1 (최근 30일)
이전 댓글 표시
Go the Home tab and, in the Environment section, click Set Path. Then we will open the Set Path dialog box, there is a 'Save' button, now I want to use a M-file to achieve the 'save' button's function, how to do this? Use 'Savepath()'? I do not want to change any path, no add, no move, no remove, just save. Like I open this dialog, do nothing, just click 'save' button and close the dialog, now I want to use M-file to do this. just save. how? thanks~
![set_path.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/144559/image.png)
채택된 답변
Walter Roberson
2019년 1월 17일
matlabpath( strjoin(Cell_Array_Of_Character_Vectors, pathsep) )
댓글 수: 17
Walter Roberson
2019년 1월 17일
Your diagram claims you are using R2017a, not R2011b...
temp = repmat({pathsep}, 1, numel(Cell_Array_Of_Character_Vectors));
temp{end} = ''; %no separator on the last one
temp = reshape([reshape(Cell_Array_Of_Character_Vectors, 1, []); temp], 1, []);
temp = horzcat(temp{:});
matlabpath( temp );
Here Cell_Array_Of_Character_Vectors is a cell array of character vector of the path elements to be stored.
But perhaps I have misunderstood. My solution is for the situation that you somehow know the complete list of items to use for the path, but you do not want to store that list permanently. My solution is not for the case where you have called pathtool in your program to open up the GUI and you want the code to somehow click "Save" without the user having to click it.
The case where you have a complete list of items to use to replace the path is not common (except that the initial path is loaded at startup time.) Much more common is the situation where you want to add a few specific locations to the path and continue executing: that case is better handled a completely different way, by calling addpath()
kei hin
2019년 1월 17일
sorry for my english, I don't understand... I just want to konw how to use a command to do the things which same as click the 'save' button.
Actually, I have a tool to change some setting to matlab environment, then I have to open the set path dialog and click 'save' button without any change then close the dialog, If I don't do this, I will got something wrong I don't konw, maybe lost path I guess. I hate this handwork(open-click save button-close), so I want a command...do we have~ thanks
For example, I want to creat a new *.m, I can use the menu bar(like click 'save' button), or I can use 'edit' command(I want this command).
Stephen23
2019년 1월 17일
"Actually, I have a tool to change some setting to matlab environment, then I have to open the set path dialog and click 'save' button without any change then close the dialog"
Ahhh, so that is the real problem that you are trying to solve: http://xyproblem.info/
It sounds like the tool might not be working properly. Can you give us a link or upload the tool?
Walter Roberson
2019년 1월 17일
Java Robot Class can potentially click for you. It is a nuisance to get right through.
Walter Roberson
2019년 1월 18일
No. savepath cannot click the save button for you, and so cannot close the pathtool you are opening. Furthermore savepath saves the path to disk, which you specifically do not want to do.
kei hin
2019년 1월 18일
편집: kei hin
2019년 1월 18일
I don't want let m-file to click the save button or close the pathtool in real(I don't want and will not open the pathtool), I just want a same result like the save button clicked without pathtool opened or closed. You mean that if I use savepath in D:\abc then the savepath function will add this path(D:\abc) into the path list? So can we use some parameter to avoid it? Like
savepath(pathlist_in_disk, 'null') %dummy
Walter Roberson
2019년 1월 18일
편집: Walter Roberson
2019년 1월 21일
ah you have a problem . Clicking the Save button in pathtool does save to disk but you do not want the change saved to disk.
The code I already posted changes the execution MATLAB path without changing the path stored on disk.
kei hin
2019년 1월 18일
편집: kei hin
2019년 1월 23일
open path set dialog--click save button--close, there is no change from me, I didn't do the add or move or else. If just click the save button will save someting to disk, it doesn't matter, anything the save button did is allowed. So I want a command to do what the save button do, can I?
kei hin
2019년 1월 23일
Click save button in pathtool dialog is same to 'savepath' in command window, isn't it?
Walter Roberson
2019년 1월 23일
I poked into the resources and can confirm that pathool save dialog invokes MATLAB's savepath()
kei hin
2019년 1월 23일
where can I find the code of pathtool? I want to know the details.
And if I want add a path, I can click add in pathtool then click save and close, can I use 'addpath' in command window? Should I have to use 'savepath' after 'addpath' in command window?
Walter Roberson
2019년 1월 23일
To get the code for pathtool, you would need to either work for Mathworks or else buy enough of the company itself to be entitled to the source code.
addpath() changes MATLAB's in-memory idea of the path. savepath() writes path data to a file.
kei hin
2019년 1월 23일
aha...OK...Let's back to the question, I can use 'savepath' to instead click save button in pathtool dialog right? So can you edit your first answer, and I will accept it.
Walter Roberson
2019년 1월 23일
If you just want to put a path into effect then the code from https://www.mathworks.com/matlabcentral/answers/440143-m-file-to-instead-save-button-in-set-path-dialog#comment_661311 does that without using savepath() .
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Search Path에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)