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

1 Ansicht (letzte 30 Tage)
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.

Akzeptierte Antwort

Friedrich
Friedrich am 21 Mai 2013
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.

Weitere Antworten (0)

Kategorien

Mehr zu Environment and Settings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by