Click here to Skip to main content
14,302,135 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi,
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:
http://up8.iranblog.com/images/69941164740732764459.png[^]

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)
{

  wb_robot_init();




  WbDeviceTag prop_ser = wb_robot_get_device("prop");


  do {



     wb_servo_set_velocity(prop_ser,3.14);
     wb_servo_set_position(prop_ser,INFINITY);



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


  wb_robot_cleanup();

  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?
thanks.
Posted
Comments
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
http://tomopt.com/docs/standalone/tomlab_sal008.php[^]

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.
   
v3

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