現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
m file to instead save button in set path dialog
3 ビュー (過去 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~
採用された回答
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!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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 (한국어)