Click here to Skip to main content
15,891,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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):


XML
#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

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.
 
Share this answer
 
v3

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900