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

1 vue (au cours des 30 derniers jours)
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.

Réponse acceptée

Friedrich
Friedrich le 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.

Plus de réponses (0)

Catégories

En savoir plus sur Environment and Settings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by