How can I create an executable file that have an input that change in each run?

1 回表示 (過去 30 日間)
Zahura
Zahura 2013 年 5 月 17 日
Hi,
I want to create .exe for this simple code:
load text.txt
A=text(:,1);
d=A(1,1);
H=A(2,1);
T=A(3,1);
disp(d);
disp(H);
disp(T);
I use mcc -m func.m -a 'E:/.../directory that contain text file'
when I'm creating .exe file, text file contains: 1 2 3
and after running executable file,it shows this result: 1 2 3
but when I change the text file: 4 5 6
executable file again shows: 1 2 3
what should I do to update this text file in each run of .exe file, when I'm creating .exe.
of course this a simple example and I need it in another complicated code.
I'm beginner, I searched and I couldn't find the similar problem
Thanks in advance.
  1 件のコメント
Zahura
Zahura 2013 年 5 月 18 日
編集済み: Zahura 2013 年 5 月 20 日
Could anyone help me out PLZ?

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

採用された回答

Friedrich
Friedrich 2013 年 5 月 21 日
Hi,
In the case you wan't an alterated input file do NOT embed it into the CTF. At startup the MCR checks if the extracted CTF content changed, if so it reextracts the CTF which leads to overwriting the file and you get back the initial values. Its better to place an input file next to the exe and determine at runtime the path to it:
This will give the desired result.
So basically instead of load text.txt do
load(fullfile(getcurrentdir,'text.txt'))
and place that text.txt in the same folder as your exe.
  1 件のコメント
Zahura
Zahura 2013 年 5 月 21 日
As you said That's work fine, I'm very thankful for your help

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by