Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Matlab scripts as ExternalCode Component

I am trying to use some existing matlab scripts within the openmdao. The external code tutorial is straight forward to follow. However, I encounter some issues when modifying the following example for matlab applications. original code in tutorial:

self.options['command'] = ['python', 'extcode_paraboloid.py', self.input_file, self.output_file]

modified code for matlab applications:

self.options['command'] = ['matlab', '-nodesktop -r "run Paraboloid.m"', self.input_file, self.output_file]

This line is okay to launch matlab. However, other arguments('-r "test.m "') seems have been truncated and can not be interpreted by matlab correctly. The alternative solution I have is to create another .py file for calling os command.

os.system('cmd /c "matlab -nodesktop -r "run Paraboloid.m",quit"')

Any suggestion on how to call the matlab function directly? Thanks!

like image 402
Sparkle Avatar asked Apr 28 '26 04:04

Sparkle


1 Answers

Try breaking everything up wherever there is a space.

self.options['command'] = ['matlab', '-nodesktop', '-r', '"run Paraboloid.m"', self.input_file, self.output_file]

like image 94
Justin Gray Avatar answered Apr 30 '26 20:04

Justin Gray



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!