Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.
Running Comsol from Windows terminal via Matlab script and calling a Matlab function
Posted 2025年2月25日 GMT+8 09:41 LiveLink for MATLAB Version 6.3 1 Reply
Please login with a confirmed email address before reporting spam
I want to run Comsol simulations in batch so I want to run it from the terminal. I am using the following command: comsolmphserver matlab -nodesktop -mlnosplash -logfile logfile.log "cd('path\to\m-file'); Honeycomb_sheet; exit"
In the path\to\m-file I have two files: Honeycomb_sheet.m and sigma_wraper.m. Honeycomb_sheet.m is a Matlab script that has all commands to run a Comsol simulation. sigma_wraper.m is a Matlab function that I call within Comsol in the Honeycomb_sheet.m. That is, in Honeycomb_sheet.m I have the following:
model.func.create('extm1', 'MATLAB'); model.func('extm1').set('clearsolve', true); model.func('extm1').set('funcs', {'sigma_wraper' 'solid.el11,solid.el22,solid.el33,solid.el12,solid.el13,solid.el23,i,j'});
However, I cannot run that simulation as I get this error:
Matlab function is not found: sigma wraper - Function: sigma_wraper
I have the file there. I think the issue is that there are two emerging windows as shown in the attached screenshot. By using pwd I noticed that one of the windows has the correct simulation directory but the other widow has the Matlab root directory as the working directory. So because of that, I think it is looking for my sigma_wraper.m in Matlab's root directory.
Is there a way to run a Comsol simulation via a Matlab script that itself calls another Matlab function?
Attachments: