Compiling with Matlab instead of interpreting

Hi,
I'm looking to compare different coding software (Matlab, Python and Labview) to know which one would be the most adept for my need. I wanted to write the same heavy calculations in the three language and see which one runs faster. I would be making a custom function and calling it a hundred times and see how long it took to execute.
To do so, I wanted to optimize my code the best I can. To my understanding, Matlab is an interpreter. He will go line by line traducting the code for the computer to execute it. I wanted to know if it was possible to compile the code in advance in a way to make it execute as fast as a compiler.
Thank you
RMT

 採用された回答

Bruno Luong
Bruno Luong 2018 年 11 月 12 日
編集済み: Bruno Luong 2018 年 11 月 12 日

1 投票

MATLAB calls FFTW library behind the scene, so if you are doing heavily FFT for convolution, there is not much speed penalty.
I recently code an algorithm in C and invokes FFTW; I can attest it's pretty hard to beat MATLAB.
It hard to say anything about speed. It depends not only which "language" you select but also where as you are beginer or expert.
In MATLAB, it can play a great role.

9 件のコメント

Image Analyst
Image Analyst 2018 年 11 月 12 日
Ealier this year the Mathworks presented some comparisons where MATLAB was comparable to Python and in most cases faster than Python.
Bruno Luong
Bruno Luong 2018 年 11 月 12 日
Do you have a link?
Bruno Luong
Bruno Luong 2018 年 11 月 12 日
編集済み: Bruno Luong 2018 年 11 月 13 日
Found this page
Image Analyst
Image Analyst 2018 年 11 月 13 日
They told us in person when I was visiting them in Natick earlier this year. I don't know of any link.
Walter Roberson
Walter Roberson 2018 年 11 月 13 日
Bruno , that comparison page also automatically flipped me to the English equivalent page .
Raphaël
Raphaël 2018 年 11 月 13 日
An important detail I forgot to mention is that I intend to run my matlab script as a function a lot of times in another program. At the moment, I would have Labview call my matlab function and I was wondering if there was any preperation I could do so that it takes less time each time he runs the function.
Thanks for the help.
RMT
Bruno Luong
Bruno Luong 2018 年 11 月 13 日
編集済み: Bruno Luong 2018 年 11 月 13 日
Believe me, calling MATLAB from LABVIEW is a bad idea, especially if you do it intensively, and if speed is important for you.
Raphaël
Raphaël 2018 年 11 月 13 日
Just making sure I studied all my options.
I'll most likelly do the calibration part of my code in Matlab since it only need to run the function once, time is far less of an issue, it's the most computation heavy and it's already written in Matlab.
Bruno Luong
Bruno Luong 2018 年 11 月 13 日
You need to pay attention to threading.
Labview is heavily multi-thread and MATLAB is mostly not threadsafe. That can create serious locking if you call stuff asynchronuously..

サインインしてコメントする。

その他の回答 (2 件)

Matt J
Matt J 2018 年 11 月 12 日

1 投票

With some limitations, you can convert Matlab code to C using the Matlab Coder and compile that.

2 件のコメント

Raphaël
Raphaël 2018 年 11 月 12 日
Do you have an idea for the limitations? I'm using fast fourrier transform and 3D convolution functions in my code.
Matt J
Matt J 2018 年 11 月 13 日
編集済み: Matt J 2018 年 11 月 13 日
Here are a few relevant links.
But I agree with Bruno. It's going to be hard to beat ordinary Matlab at FFT and convolution operations, especially if you do those computations on the GPU using the Parallel Computing Toolbox.

サインインしてコメントする。

Image Analyst
Image Analyst 2018 年 11 月 12 日

0 投票

1 件のコメント

Bruno Luong
Bruno Luong 2018 年 11 月 12 日
MATLAB compiler actually doesn't compile anything. It just encrypt/package the source code to run under the runtime.
In this perspective, the speed gain is 0.

サインインしてコメントする。

カテゴリ

質問済み:

2018 年 11 月 12 日

コメント済み:

2018 年 11 月 13 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by