在 matlab 中编写一个非常基本的 mex 函数
Writing an extremely basic mex function in matlab
我正在尝试编写一个非常简单的 mex 文件,假设只是为了尝试它的工作方式。我浏览了很多材料,我读的越多,我就越困惑。我需要它来进一步编写与外部硬件交互的 mex 文件。请帮忙!
// header file - printing.h //
#include<iostream>
class printing
{
public:
void name();
void age();
};
// cpp file - printing.cpp //
#include<iostream>
#include "mex.h"
#include "matrix.h"
#include "printing.h"
#include <string>
using namespace std;
void mexFunction(int nlhs, mxArray*plhs[],
int nrhs, const mxArray *prhs[])
{
printing p1;
p1.name();
p1.age();
}
void printing::name()
{
cout << "NAME" << endl;
}
void printing::age()
{
cout << "20" << endl;
}
.m 文件 - test.m//
sprintf ('WELCOME')
printing()
当我运行test.m文件时,我想看到欢迎名字20但是,我只看到欢迎。我知道我没有更新 plhs[] 数组。但是我想做的只是在 mexFunction 中执行一些东西,为什么 name() 和 age() 中的 cout 不能实现这一点?
另外,如何确认 name() 和 age() 已执行?
调用cout
不会打印到 MATLAB 控制台,需要使用 MEX printf 函数。
mexPrintf("NAMEn");
相关文章:
- 我从int x[3]得到的一个非常奇怪的输出;
- 一个非常简单的win32套接字代码,但工作错误
- 超过CPU时间限制:当MPI_Sent一个非常大的int*时
- 无法使用crfsuite的C++ API编译一个非常简单的Tagger示例
- 维护/维持两个代码集的风险,一个用于 CPU,一个用于 GPU,需要执行非常相似的功能
- C++中一个非常简单的枚举类错误
- 新的一个一维阵列,非常大,例如60000*60000
- 一个关于在函数中运行未调用语句的非常奇怪的错误
- 我在内存泄漏和字符串方面遇到了一个非常奇怪的问题
- 我正在写一个非常简单的字母评分系统,if语句是最有效的吗?
- 我刚刚创建了一个非常快速的素数排序方法.如何改进?
- 我的调试器说我有一个隔离错误错误,但无法告诉我在哪里,在非常特殊的情况下发生
- 在64位系统上创建一个非常大的数组的缺点是什么
- (c++)代码中一个非常奇怪的问题
- 打印出一个非常小的浮点数
- C++:C字符串、指针和一个非常有趣的while循环
- 在 matlab 中编写一个非常基本的 mex 函数
- 在C 中编写一个非常简单的事件类
- 如何取一个非常大的数的根
- 在使用Qt Creator创建一个非常简单的项目时,在Qt中遇到"segmentation fault"