matlab2c使用c++实现matlab函数系列教程-histc函数
来源:互联网 发布:json 增加元素 编辑:程序博客网 时间:2024/05/16 13:25
全栈工程师开发手册 (作者:栾鹏)
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中histc函数简介
1、histc函数:
返回各区间的数目多少,返回列向量
2、用法说明
histc函数制定数值边界为分界条件
histc以 a=[1 2 3 4 5 6 7 8 9 0 ], edges=1:2:7 为例。
[n,bin]=histc(x,edges)
返回n=[2 2 2 1],
bin=[ 1 1 2 2 3 3 4 0 0 0]。
edges=1:2:7即总共有三个数值分界,分别为1<=x<3, 3<=x<5, 5<=x<7,
n(1)=2表示a中落在第一个范围的数总共有两个,1和2;
n(2)=2表示a中落在第二个范围的数总共有两个,3和4;
n(3)=2表示a中落在第三个范围的数总共有两个,5和6;
n(4)=1表示a中的值等于edges最后一个值7的个数为1。
bin的值为a中的值分别在edges的哪个范围中(1就是在edges的第一个空中),若不在edges范围中,则返回0。
histc的c++源码实现
返回各区间的数目多少,返回列向量
输入:数据序列a,边界序列edg
输出:数据序列a中的元素在edg序列各区间上的个数的多少
提示:区间为左闭右开,返回列向量
Matrix Matlab2c::histc(Matrix& a,Matrix& edg){ int i=0,j=0; Matrix p(edg.row*edg.column,1); for (i=0;i<p.row;i++) p.data[i]=0; for (i=0;i<a.row*a.column;i++) for (j=edg.row*edg.column-1;j>-1;j--) if((a.data[i])>=(edg.data[j])) { (p.data[j])++; //大于等于小区间下边界,小于小区间上边界的数据的个数.最后一个存储等于最后一个值的个数 break; } return p;}
histc函数的使用测试
#include "Matlab2c.h"#pragma comment(lib,"Matlab2c.lib") using namespace Matlab2c;int main(){ double a[]={1,2,3,4,5,6,7,8}; double edge[]={1,4,6}; Matrix aa=Matrix(1,8,a); Matrix bb=Matrix(1,3,edge); Matrix cc=Matlab2c::histc(aa,bb); cout<<cc.toString()<<endl; system("pause"); return 0;}
- matlab2c使用c++实现matlab函数系列教程-histc函数
- 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函数
- ORB-SLAM2 mono-kitti 系统分析图
- Javascript实现自定义菜单树
- Hibernate缓存的实现
- IDEA的安装破解教程和使用说明(三)
- Java面试题整理
- matlab2c使用c++实现matlab函数系列教程-histc函数
- 位运算编程题三道
- Thymeleaf简介
- stm32f4使用Systick实现延时
- input系统
- Subclipse talks to Subversion via a Java API解决方案
- 2017年滴滴秋招内推笔试编程题
- 爬虫学习——爬虫之新浪新闻
- 【设计模式】装饰者模式-明月装饰了你的窗子