Running Ansys from Matlab

Hi,
I need to run Ansys from Matlab. I write the code
dos('ansys145 -b -i model2.txt -o output2.txt');
Then I get an error
ansys145 is not recognized as an internal or external command, operable program or batch file.
I try adding "C:\Program Files\ANSYS Inc\v145\ansys\bin\winx64\ANSYS145.exe" as a path to Environmental Variables but the problem is not solved.

13 Comments

What happens if you try running the same command outside of MATLAB, in the DOS/Command window - does that work?
And did you add C:\Program Files\ANSYS Inc\v145\ansys\bin\winx64\ANSYS145.exe to the Environment Path variable, or C:\Program Files\ANSYS Inc\v145\ansys\bin\winx64\ where the latter has just the path to the application and not the application name?
I added "C:\Program Files\ANSYS Inc\v145\ansys\bin\winx64\ANSYS145.exe" to the Environmental Path and this did not work. I solve problem by changing the command as
dos('"C:\Program Files\ANSYS Inc\v145\ansys\bin\winx64\ANSYS145.exe" -b -i model2.txt -o output2.txt');
It would have been interesting to see if just adding C:\Program Files\ANSYS Inc\v145\ansys\bin\winx64 to the environment PATH would have been sufficient because I think that you typically add paths to this variable and not files or executables (along with their path).
Hello Merve & Geoff
I used the code
!"C:\Program Files\ANSYS Inc\v160\ansys\bin\winx64ANSYS160.exe" -b -i C:\Users\cfo1714\python\s3.txt -o C:\Users\cfo1714\python\output.txt
and I also used
dos('"C:\Program Files\ANSYS Inc\v160\ansys\bin\winx64ANSYS160.exe" -b -dir "C:\Users\cfo1714\python" -i "C:\Users\cfo1714\python\s3.txt -o C:\Users\cfo1714\python\output.txt"')
I got the same result, which is
'"C:\Program Files\ANSYS Inc\v160\ansys\bin\winx64ANSYS160.exe"' is not recognized as an internal or external command,
operable program or batch file.
ans =
1
Please help me, in solving the problem
Mohan prasad K S, you appear to be missing the \ between winx64 and ANSYS160.exe
Check with your Windows Explorer that you are using exactly the same path and file name as your ANSYS executable.
Hi Guys I am facing the same issue
dos( ' "C:\Program Files\ANSYS Inc\v162\ansys\bin\winx64\ANSYS" -b -i C:\New folder\matlabex\ansyscampbell\in.txt -o C:\New folder\matlabex\ansyscampbell\out.txt ');
but ansys is not working, and I am geting ans vaule = -1.0737e+09
can any one help please. thanks
Sorin Munteanu
Sorin Munteanu on 26 Feb 2017
Edited: Walter Roberson on 26 Feb 2017
Hi Prakul,
I will suggest to use interactive connection between Matlab and ANSYS (aka the ANSYS aaS connection). The link provided by Sarah is a very good start ( MATLAB Apps For ANSYS )
Using ANSYS aaS you will be able start Matlab and ANSYS on two different machines (e.g. Matlab on Windows and ANSYS on Linux) and connect them. You will be able then to issue one command(i.e. one line in your in.txt) at the time and retrieve the output/error for each command.
The approach that you mentioned will implicitly require ANSYS and Matlab running on the same machine, and further more ANSYS will most surely execute in the memory of the Matlab process, therefore it will be applicable only to relative small academic ANSYS simulations. The aaS approach will let you to execute large ANSYS simulation too, e.g. parallel simulations running on multiple compute node on a Linux cluster. On top of thatm with aaS, you do not have to wait for ANSYS simulation to complete and read the output file, but you will be updated by the simulation progress as this is executed.
Sorin
Prakul, try
dos( ' "C:\Program Files\ANSYS Inc\v162\ansys\bin\winx64\ANSYS" -b -i "C:\New folder\matlabex\ansyscampbell\in.txt" -o "C:\New folder\matlabex\ansyscampbell\out.txt" ');
That is, every path should have "" around it, so that if it happens to have a space in it, dos will not break it up into two arguments.
Hi Sorin & Walter,
Thanks for the input.
Hello,
I want to run fluent from matlab and i can't use AAS toolbox because i don't access to it, how can i run multiple times ?
i use it :
! "C:\Program Files\ANSYS Inc\v212\fluent\ntbin\win64\fluent.exe" 2ddp -i "C:\Users\SINA\Desktop\New_folder\15KArms.jou" '
but i want to run again this file by another journal file after finishing the first journal file i mean in following of first journal . How can i do it?
Best Regards,
exe_path = 'C:\Program Files\ANSYS Inc\v212\fluent\ntbin\win64\fluent.exe';
jou_dir = 'C:\Users\SINA\Desktop\New_folder';
dinfo = dir(jou_dir, '*.jou');
numfiles = length(dinfo);
messages = cell(numfiles, 1);
for K = 1 : numfiles
jou_file = fullfile(dinfo(K).folder, dinfo(K).name);
cmd = sprintf('"%s" 2ddp -i "%s"', exe_path, jou_file);
[status, messages{K}] = system(cmd);
end
Thank you for your response and guidance,It's so helpfull. But I have a problem , i want pop up fluent for one time and then run it by some journal file multiple time in the following of Previous one , i dont want to pop up fluent for every journal file separately, is there any solution for it?
Best regards,
nice answer, would like to more about that

Sign in to comment.

 Accepted Answer

Sarah Palfreyman
Sarah Palfreyman on 10 Jan 2017
See ANSYS for the MATLAB AAS Toolbox interface.

6 Comments

That doesn't solve the issue in the case of having a ANSYS students license.
It seems to have nothing there. Can you please tell me the newest website?
As discussed below, the company moved their software to a website that the public and students do not have access to.
The software when it was available was only for a range of MATLAB releases roughly 8 years ago.
https://forum.ansys.com/forums/topic/download-matlab-toolbox-ansysaas/ suggests that students try to find someone with a paid TECS support account, which can access the customer portal and so download the software (or at least could in the past; I do not know if it is still there.)
is there any news about live data exchange between ansys and matlab?
The toolbox is now availabe for download from Mathworks File Exchange at
Sorin

Sign in to comment.

More Answers (2)

broken_arrow
broken_arrow on 17 May 2021
Edited: broken_arrow on 8 Oct 2021
As of today, the provided link
redirects to the Ansys start page. The latest ANSYS_aaS Toolbox I could get is 1.1.9, which officially works until Matlab R2018b. I couldn't get it to work with newer releases and also can't downgrade my Matlab release because I'm using some functionalities of newer releases. Is there any follow-up on this? Has Ansys aaS been discontinued?

3 Comments

The blog appears to have moved to
Unfortunately the toolbox they mention there cannot be searched for on their site -- it looks like public and students cannot gain access to the place in the Customer Portal that has the toolbox.
Thanks for providing the new link. Still, the time stamp is from 2017 and according to the text, the toolbox works for Matlab releases from 2014b through 2016a. It would be great to get an update on the state of things (@Sarah Palfreyman, @MathWorks Support Team).
The toolbox is now availabe for download from Mathworks File Exchange at
I updated it and It support all Matlab versions from 2014b to 2023b and ANSYS versions from R15 to R23.2
Thank you
Sorin

Sign in to comment.

Categories

Products

Asked:

on 20 Sep 2014

Commented:

on 16 Nov 2023

Community Treasure Hunt

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

Start Hunting!