从C调用matlab m文件 [英] calling matlab m files from C

查看:74
本文介绍了从C调用matlab m文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在使用用于机器人建模的软件.
它的名字叫WEBOTS.我们用C对机器人的控制器进行编程.
那是一个简单的带有末端螺旋桨的火箭:
http://up8.iranblog.com/images/69941164740732764459.png [

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;
}




现在,我在matlab中创建了一个m文件功能,我想在我的C代码中调用此文件.
我该怎么办?
谢谢.




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.

推荐答案

我在matlab上经验很少,但可以为您提供帮助
http://tomopt.com/docs/standalone/tomlab_sal008.php [ ^ ].还可以将这些共享库集成到Visual Studio应用程序中.
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.


这篇关于从C调用matlab m文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆