Click here to Skip to main content
14,302,135 members
Rate this:
Please Sign up or sign in to vote.
See more:
Im using a software for robotics modeling.
Its name is WEBOTS. we program the controller of robot with C.
Thats a simple rocket that have a propeller in its end:[^]

Thats its controller in C (in WEBOTS):

#include <webots/robot.h>
#include <webots/servo.h>
#include <stdio.h>
#include <math.h>

#define TIME_STEP 64

int main(int argc, char **argv)


  WbDeviceTag prop_ser = wb_robot_get_device("prop");

  do {


  } while (wb_robot_step(TIME_STEP) != -1);


  return 0;

Now I made a m-file function in matlab and I want to recall this file in my C code.
How can I do it?
Albert Holguin 29-Jan-12 19:30pm
This is a common question, have you bothered to look online for an answer?

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

i have little very little experience in matlab but it can help you[^]

You can convert MATLAB code into a C or C++ shared library using the MATLAB Compiler. This shared library can then be incorporated into a Visual Studio project, or be combined with a driver file into a stand-alone application. To compile your MATLAB code, for example foo1.m and foo2.m, into a C shared library use the following syntax:

mcc -B csharedlib:libmyfoo foo1.m foo2.m
For an example on building a C shared library and a driver file, refer to the C shared library example[^] of the documentation. It is further possible to integrate these shared libraries into Visual Studio applications.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100