フィルターのクリア

How to read .ini file dynamically during runtime using standalone application created using Matlab Compiler

41 ビュー (過去 30 日間)
I have a GUI created in Matlab, and it reads an .ini file to obtain the initial parameter settings to the GUI. The .ini file is treated as a normal text file and its contents are read via functions like fopen(), fgets(), fclose(). This worked fine when executed in Matlab.
My question would be, how do I also enable this after compiling my GUI into a standalone application using Matlab Compiler? I would like my .ini file to be included as an external file to my main (.m file).
Thanks in advance!

採用された回答

Friedrich
Friedrich 2013 年 8 月 12 日
編集済み: Friedrich 2013 年 8 月 12 日
Hi,
use this and place the .ini file in the same folder as your exe. In that way the user can modify the ini file and everytime the exe starts, the changes are read in and used.
So something like
%call getcurrentdir, and read the ini file
file = fullfile(getcurrentdir,'myFile.ini')

その他の回答 (1 件)

David Sanchez
David Sanchez 2013 年 8 月 12 日
You can use the uigetfile function within your GUI main *.m file.
[FileName,PathName] = uigetfile('*.ini','Select the INITIALIZATION file');
ini_path = fullfile(PathName, FileName);
The *.ini file will become user selectable.
For all the details:
doc uigetfile
  1 件のコメント
Chong
Chong 2013 年 8 月 13 日
Thanks for your swift reply! However my intention is to make my GUI automatically locate the .ini file, instead of prompting the user for the file...

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMATLAB Compiler についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by