How to run a MATLAB file without opening the MATLAB GUI?

조회 수: 21 (최근 30일)
Pierre
Pierre 2025년 2월 27일
이동: Mike Croucher 2025년 2월 27일
Hello,
I am trying to test a batch file that runs matlab with an input file
the batch file is one line:
"C:\Program Files\MATLAB\R2024b\bin\matlab.exe" -noFigureWindows -minimize -nosplash -r "c:\tmp\test\test_matlab_no_GUI_batch.m"
the MATLAB file is:
a=6;
b=7;
c=a+b;
dlmwrite('c:\tmp\test\HFSS_Batch\test_matlab_no_gui.txt',c)
I would expect to see the "test_matlab_no_gui.txt" file in "c:\tmp\test\" folder.
I am not. what am I missing?
Thank you

채택된 답변

Mike Croucher
Mike Croucher 2025년 2월 27일
편집: Mike Croucher 2025년 2월 27일
You need to wrap your script in a run command. I also suggest using the newer, -batch switch
"C:\Program Files\MATLAB\R2024b\bin\matlab.exe" -batch "run('C:\Users\walki\battest.m')"
Alternatively, add your directory to the MATLAB path before running the script. Like this
"C:\Program Files\MATLAB\R2024b\bin\matlab.exe" -batch "addpath('C:\Users\walki\');battest"
  댓글 수: 2
Pierre
Pierre 2025년 2월 27일
이동: Mike Croucher 2025년 2월 27일
thanks, will try
Pierre
Pierre 2025년 2월 27일
이동: Mike Croucher 2025년 2월 27일
that worked, thanks again

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by