matlab2c使用c++实现matlab函数系列教程-ismember函数
来源:互联网 发布:vb是什么意思啊 编辑:程序博客网 时间:2024/06/05 10:24
全栈工程师开发手册 (作者:栾鹏)
matlab2c动态链接库下载
matlab库函数大全
matlab2c基础教程
matlab2c开发全解教程
matlab2c调用方法:
1、下载动态链接库
2、将Matlab2c.dll拷贝到exe同目录下
3、将Matlab2c.h、Matlab2c.lib放到项目头文件目录下
4、在cpp文件中引入下面的代码
#include "Matlab2c.h"#pragma comment(lib,"Matlab2c.lib") using namespace Matlab2c;
matlab中ismember函数简介
1、ismember函数:
检测集合中的元素是否处在另一个集合中2,3…,然后再从第二列,第三列依次往后数)
2、用法说明
A=[1,1,2,4,4,3];
B=[1,2,5];
[m,n]=ismember(A,B); //m矩阵表示A中元素是否出现在B中,0表示未出现,1表示出现。n矩阵表示A中元素在B中的位置,0表示未出现。
ismember的c++源码实现
检测集合中的元素是否处在另一个集合中
输入:集合a,集合b
输出:返回行向量指针,第一个向量记录a中的元素是否存在b中,第二个向量记录a中的元素在b中的位置,不存在则为-1
提示:集合是一个行向量,即一维矩阵,下标从0开始,不存在为-1
Matrix* Matlab2c::ismember(Matrix& a,Matrix& b){ bool exist=false; Matrix *p; Matrix p1(1,a.column); //记录a中的元素是否存在b中,存在为1,不存在为0 Matrix p2(1,a.column); //记录a中的元素在b中的位置,不存在则为-1 p = new Matrix[2]; for (int j=0;j<a.column;j++) { int n=0; exist=false; for (n=0;n<b.column;n++) if (a.data[j]==b.data[n]) { exist=true; break; } if (exist) { p1.data[j] = 1; p2.data[j] = n; } else { p1.data[j] = 0; p2.data[j] = -1; } } *p = p1; *(p+1)=p2; return p;}
ismember函数的使用测试
#include "Matlab2c.h"#pragma comment(lib,"Matlab2c.lib") using namespace Matlab2c;int main(){ double a[]={1,1,2,4,4,3}; double b[]={1,2,5}; Matrix aa=Matrix(1,6,a); Matrix bb=Matrix(1,3,b); Matrix* cc=Matlab2c::ismember(aa,bb); cout<<(*(cc+0)).toString()<<endl; cout<<(*(cc+1)).toString()<<endl; system("pause"); return 0;}
阅读全文
2 0
- matlab2c使用c++实现matlab函数系列教程-ismember函数
- matlab2c使用c++实现matlab函数系列教程-blkdiag函数
- matlab2c使用c++实现matlab函数系列教程-compan函数
- matlab2c使用c++实现matlab函数系列教程-eye函数
- matlab2c使用c++实现matlab函数系列教程-hankel函数
- matlab2c使用c++实现matlab函数系列教程-hilb函数
- matlab2c使用c++实现matlab函数系列教程-ones函数
- matlab2c使用c++实现matlab函数系列教程-zeros函数
- matlab2c使用c++实现matlab函数系列教程-pascal函数
- matlab2c使用c++实现matlab函数系列教程-toeplitz函数
- matlab2c使用c++实现matlab函数系列教程-wilkinson函数
- matlab2c使用c++实现matlab函数系列教程-diag函数
- matlab2c使用c++实现matlab函数系列教程-tril函数
- matlab2c使用c++实现matlab函数系列教程-triu函数
- matlab2c使用c++实现matlab函数系列教程-fliplr函数
- matlab2c使用c++实现matlab函数系列教程-flipud函数
- matlab2c使用c++实现matlab函数系列教程-reshape函数
- matlab2c使用c++实现matlab函数系列教程-rot90函数
- spring学习笔记五 bean的作用域
- python机器学习核心算法3-3
- 装扮模式
- 【数据结构和算法】Day 17
- J
- matlab2c使用c++实现matlab函数系列教程-ismember函数
- Meta http-equiv属性详解
- There is no getter for property named 'id' in 'clas
- 自定义VIew
- C和指针第十一章的编程习题
- JQuery之工具类函数
- idea 快捷键
- java获取文件创建时间
- 单调队列优化dp