Calling MATLAB from YADE

Asked by Pouyan on 2020-02-25


I need to call a pretrianed MATLAB ANN from YADE to calculate drag force (

The MATLAB engine "matlab.engine.start_matlab" enable Python to call MATLAB functions . The command simply return input and output arguments.

I could call the MATLAB script to compute the drag force from a python script.

However, when I run a .py script from terminal using "python yade", I face the error "Segmentation fault (core dumped)". contains the following:

from yade import pack, plot
import matlab.engine

Has anyone had the same problem?

Thanks in advance,


Question information

English Edit question
Yade Edit question
No assignee Edit question
Last query:
Last reply:

Dear Poyan,
There can be many reasons for such a segfault unfortunately.
I have absolutely no experience with interfacing matlab and python.
BUT, your test script suggests a library problem I think. Random ideas:

1. is it possible to reproduce the segfault _without_ yade, by importing the most obvious python dependencies of yade: matplotlib, numpy, ... such things.

2. could it be that matlab ships its own version of libraries like cholmod or lapack (I wouldn't be surprised, and then segfault because the same library has two versions)?

3. could you try the same thing with a debug build of yade? a debug build of matlab? At least you would know where the crash comes from.

4. possible workaround: instead of starting yade as a program, start python and import yade (so you can e.g. load matlab first, then yade). All you need to do that is to create a symlink to yade executable that you'll name *.py. See an example here [1].

I hope it helps.


Oh wait, what is this?
> "python yade"

This is not a possible yade invocation.
Choose between python and yade (as explained in point 4), not both.


Can you help with this problem?

Provide an answer of your own, or ask Pouyan for more information if necessary.

To post a message you must log in.