环境:vs2015、Matlab2020
VS2015中建立工程,
建立工程如下两图所示
在头文件和源文件中分别添加头文件和源文件(代码如下所示)
头文件matdll.h文件
#pragma once
#ifndef MATDLL_H
#define MATDLL_H
#ifdef __cplusplus
extern "C"
{
#endif
//自定义输出函数
__declspec(dllexport) double add(double x, double y);
#ifdef __cplusplus
}
#endif
#endif
源文件:mat.cpp
#include "matdll.h"
double add(double x, double y)
{
return (x + y);
}
在Matlab中调用
首先需要将动态