# Executing Matlab function from Processing

**URL:** <https://discourse.processing.org/t/executing-matlab-function-from-processing/4324>\
**Category:** Libraries\
**Created:** [October 10, 2018, 12:29pm UTC](https://discourse.processing.org/t/executing-matlab-function-from-processing/4324 "2018-10-10T12:29:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubinj](https://avatars.discourse-cdn.com/v4/letter/r/e79b87/32.png) [@rubinj](https://discourse.processing.org/u/rubinj)\
**Post date:** [October 10, 2018, 12:29pm UTC](https://discourse.processing.org/t/executing-matlab-function-from-processing/4324/1 "2018-10-10T12:29:31Z")

</div>

I’m trying to find a way to execute a Matlab function from a Processing script.

I have a local installation of Matlab, and I know it should be possible to execute a Matlab function from Java, using Matlab’s engine:  
https://www.mathworks.com/help/matlab/matlab\_external/execute-matlab-functions-from-java.html

However, when I’m trying something similar from within a Processing sketch, I get the following error:

 ![05](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/9/901db9eb94ceb74db74a0f98a794ed1255c03745.jpeg)

Any ideas?

Thanks in advance,  
Rubin

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [October 14, 2018, 5:50am UTC](https://discourse.processing.org/t/executing-matlab-function-from-processing/4324/2 "2018-10-14T05:50:00Z")

</div>

Were you able to get this to work?

It sounds like you are missing requirements that need to be installed for the Java API to work – but if that isn’t it, can you execute Matlab scripts from the command line? If so, perhaps you could use `exec()`.

Another possibility is, if you need math processing and Processing rendering combined but don’t need MatLab or Java code specifically, you could use the Processing.R mode, which gives you the R language and the Processing Java API.
