My command runs with the cmd but not with the dos matlab function. Why ?
2 views (last 30 days)
Show older comments
I want to launch an ANSYS simulation from Matlab by using the "dos" function. It asks to execute the following dos command:
"C:\Program Files\ANSYS Inc\v150\ANSYS\bin\winx64\ansys150.exe" -p aa_t_a -dir "E:\MEF_pre" -j "Simu" -s read -l en-us -b -i "E:\MEF_pre\Conditions_limites_volume_AllAtOnce.f" -o "E:\MEF_pre\file.out"'
When I enter the command line in the cmd, everything work perfectly. But when I execute the command from Matlab with "dos" or "!" the simulation stops at the first iteration with a simple error window ("Mechanical APDL Program stopped working") without any diagnosis. Why do I have two different results with apparently the same entry?
I use Matlab R2014b, ANSYS v15.0.7 and windows 7 64 bits. I use the dos function as follow:
>> dos('"C:\Program Files\ANSYS Inc\v150\ANSYS\bin\winx64\ansys150.exe" -p aa_t_a -dir "E:\MEF_pre" -j "Simu" -s read -l en-us -b -i "E:\MEF_pre\Conditions_limites_volume_AllAtOnce.f" -o "E:\MEF_pre\file.out"');
2 Comments
Mustafa Al-Bazoon
on 20 Dec 2016
Hey did you get the problem solved? I succeeded passing the info from Matlab to ANSYS. However, there are no output files. It just solves the problem without results.
Varun Goyal
on 31 Aug 2017
Hey! My data is not passing to the ANSYS either. Can you help me resolve the same? I am trying to run ANSYS through MATLAB with an input file to be input in command prompt of ANSYS. But it says Mechanical APDL has stopped working.
Accepted Answer
More Answers (1)
Image Analyst
on 4 Jul 2016
Edited: Image Analyst
on 4 Jul 2016
Without trying it, my guess is that it's getting confused over all the single and double quotes. My recommendation is to create your command line string with sprintf() first, then pass that into dos() and see if it works
commandLine = sprintf(.............) % Create command line string.
fprintf('CommandLine = %s\n', commandLine); % Print it to MATLAB's command window.
dos(commandLine) % Execute it
For the paths that don't have any spaces in them, you might try just putting them down without wrapping them in double quotes. Paths with spaces in them (like Program Files) will still need to be wrapped in double quotes.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!