Samdish Arora
Samdish Arora

Reputation: 89

Is it possible to embed MATLAB code on Raspberry pi to make standalone hardware device?

I want to realise a computer vision algorithm, coded in MATLAB on a hardware. I know that I can use serial communication to interact with MATLAB and Arduino through pc. But, I want to create a standalone hardware device. Is it possible to accomplish the task using a Raspberry Pi board. Will I be able to burn my code onto it, and use it solely to control other hardware (like a relay,etc.) that I need to?

Upvotes: 3

Views: 1466

Answers (2)

frarugi87
frarugi87

Reputation: 2880

As a researcher, I used Matlab a lot. And my preferred work pattern was

  1. Use Matlab to analyze a lot of different algorithms
  2. Find the best algorithm (fastest, most precise, ... you can define "best" in many different ways)
  3. Once the best algorithm is defined, port it to C++/C#/python (it depended on the final application)

The reason? Matlab code is slooooooooooooooooow and very poorly portable, but it already have lots of functions. So when you have to switch between algorithms it's a good choice, but once you decide the best algorithm you'd better switch to better languages.

For your case, if the application is already in the "searching for the best algorithm" phase you don't need to move it to a raspberry. If you already found it, port it to C/C++ and compile it on a raspberry, or port it to python and execute it

Upvotes: 0

Daniel
Daniel

Reputation: 36710

There are two solutions you can use.

The Raspberyy Pi Support Package from Simulink is designed to write standalone applications which run on the Raspberry Pi. This requires you to switch from Matlab to Simulink. Using a MatlabFunction Block in Simulink you should be able to reuse large parts of your code, only requiring you to redo the actual connection to the IO.

The second alternative is using the matlab coder to generate C++ from your matlab code.

Before reading any documentation page about these options, check the price tags for the required toolboxes. I think the Simulink coder is required for the Simulink support package, but I am unable to find that Information.

Upvotes: 1

Related Questions