필터 지우기
필터 지우기

how to reduce the calculation time when calling a .exe file from a MATLAB function

조회 수: 1 (최근 30일)
I'm going to use "gamultiobj" genetic algorithm multi objective function optimisation and in my objective function I call an .exe file instead of defining it directly in MATLAB. I tried two simple parabolic functions as my objectives (a given example in MATLAB help for gamultiobj). It takes 26 seconds when use objective functions defined in MATLAB, but when I call a .exe file which calculates same functions, it takes 21 minutes!! Is this normal? Is there any way to reduce the time? Will the time reduce if I convert my Fortran program to a MEX file and call this one instead of compiled .exe file?
  댓글 수: 6
Mohsen2015
Mohsen2015 2015년 6월 29일
exe is an executable file which I make by compiling ny fortran program and then call it from MATLAB as below:
function y = myfun(x)
%write the x data
xh = fopen('x.txt', 'w');
fprintf(xh, '%f %f\n', x);
fclose(xh);
%run your program
system('test3.exe');
%read the f data
fh = fopen('f.txt');
y = fscanf(fh, '%f %f');
fclose(fh);
end
but execution time to optimise "myfun(x)" with any procedure in MATLAB takes much more time than the case that I directly write the function in "myfun(x)".
Quy Nguyen
Quy Nguyen 2024년 4월 12일
i have a project that generates exe files from matlab/guide. Instructions on how to reduce matlab exe application processing time

댓글을 달려면 로그인하십시오.

답변 (1개)

Sean de Wolski
Sean de Wolski 2015년 6월 29일
Without knowledge of how the exe works this is hard to answer.
One thing you might want to try, if you are calling the exe multiple times is parfeval in the Parallel Computing Toolbox. This will allow you to submit asynchronous calls to the exe and the file read in parallel so that it can be running multiple times concurrently. This won't speed up calling the exe but will allow you to call it more frequently.

카테고리

Help CenterFile Exchange에서 Fortran with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by