How can I create an executable file that have an input that change in each run?
1 次查看(过去 30 天)
显示 更早的评论
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.
采纳的回答
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!