필터 지우기
필터 지우기

Where should I save my own app prefereces?

조회 수: 8 (최근 30일)
Micke Malmström
Micke Malmström 2017년 2월 2일
편집: Walter Roberson 2017년 2월 6일
I have my AppDesigner-app and I want it to remember the settings from last session. How and where should i prefereably save the state of the program?
  댓글 수: 1
Micke Malmström
Micke Malmström 2017년 2월 6일
Maybe C:\Users\username\AppData\Roaming\Matlab\ is a good place?

댓글을 달려면 로그인하십시오.

채택된 답변

Guillaume
Guillaume 2017년 2월 6일
If you want to do that properly, the directory (on Windows post XP) where to save the preferences would be:
fullfile(getenv('APPDATA'), yourprogramname) %and NOT matlab!
if you want the settings to get propagated to other domain computers the user log onto, or
fullfile(getenv('LOCALAPPDATA'), yourprogramname)
if the settings are local to the user and machine. IF the settings are the same to all users, then:
fullfile(getenv('PROGRAMDATA'), yourprogramname)
As to how, saving them in a mat file would be the simplest thing. Alternatively, if you want the user to be able to edit the setting file with a text editor, serialise to json or xml, or write your own parser for an INI style file.
  댓글 수: 1
Micke Malmström
Micke Malmström 2017년 2월 6일
thanks! exactly the responce i was hoping for.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2017년 2월 6일
편집: Walter Roberson 2017년 2월 6일
As a complete alternative to Guillaume's correct answer:
You can also use setpref() and the related getpref()
"Note: Preference values are persistent and maintain their values between MATLAB sessions. Where they are stored is system dependent."
These would be per-user.
By the way: I have found in practice that one of the real challenges of preference files is backwards compatibility. "Oh, gosh, a phi of 1.69 isn't even possible now! But if they had that in their preferences file 4 years ago then they must have been doing this kind of analysis and that requires interpreting the other preferences a completely different way...."

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by