Problem with .executable program

Hello,
I have a problem with a code. I create an .exe file, that cames from a matlab code.
I used the command:
clc
clear
mcc -m file.m
I have to mention that my matlab code use a file "data.txt" that takes one number in order to tun a subroutine in my matlab code.
I realised that I have to execute again and again my matlab code in order to execute the program , when I want to change the content of "data.txt".
My full code of .m file is:
clc
clear
data=regexp(fileread('data.txt'), '\r?\n', 'split') .';
data_new=data{1}
calculations.m
("calculations.m" is a subroutine I use)
Does anybody knows how can I avoid again and again execution, and to make automatically the changes I want?

4 comentarios

Rik
Rik el 8 de Mayo de 2020
Well, since you don't show multiple iterations of anything it is difficult to help you.
Does calculations need the variable data_new ? Or does it need data.txt to be rewritten to have only one line (per run) of the contents of data.txt that the code starts with?
Why not rewrite calculations to be a function that accepts a line? Then you could do things like
all_results = cellfun(@calculations, data)
Well, I use
data_new={1}
in order to replace a line of an input file that is used to run an .exe file (let's call ite second.exe)
calculations.m subroutine makes calculation from all above. But the problem is that I want to rewrite the "data.txt" and makin all this process again by the new content od "data.txt".
To summurize that my code:
1)reads the content of "data.txt"
2)put the content of the "data.txt" to a specific line in the "input.txt"
3)runs "second.exe" taking the "input.txt"
4)Do calculations using the calculations.m subroutine
The problem is that content of data.txt is changing but .exe code I am making does not taking into accound thw change of the content of "data.txt"
Walter Roberson
Walter Roberson el 8 de Mayo de 2020
How are you doing the updating of input.txt ?
You say you want to rewrite "data.txt" but your steps show that second.exe needs input.txt and I do not see anywhere in your steps that needs a new version of data.txt .

Respuestas (0)

La pregunta está cerrada.

Preguntada:

el 8 de Mayo de 2020

Cerrada:

el 20 de Ag. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by