matlab2c使用c++实现matlab函数系列教程-max函数
来源:互联网 发布:二手交易软件排名 编辑:程序博客网 时间:2024/06/05 19:34
全栈工程师开发手册 (作者:栾鹏)
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中max函数简介
1、max函数:
返回一个数组各不同维中的最大元素。
2、用法说明
C = max(A,dim)
如果A是一个向量,max(A)返回A中的最大元素。
如果A是一个矩阵,max(A)将A的每一列作为一个向量,返回一行向量包含了每一列的最大元素。
如果A是一个矩阵,max(A,dim),dim=1按列求,dim=2按行求
max的c++源码实现
求一个数组不同维度的最大值
输入为一个向量时,输出为一个1x1的矩阵
输入为一个矩阵,输出为每列最大值向量。
dim=1(默认)按列求最大值,dim=2按行求最大值
函数声明Matrix max(Matrix& a,int dim=1);函数定义Matrix Matlab2c::max(Matrix& a,int dim){ if(a.isVector()) { Matrix p(1,1); double maxitem=DBL_MIN; for (int i=0;i<a.row*a.column;i++) if(maxitem<a(i)) maxitem=a(i); p.data[0]=maxitem; return p; } else { if (dim==1) { Matrix p(1,a.column); double maxitem=DBL_MIN; for (int j=0;j<a.column;j++) { maxitem=DBL_MIN; for (int i=0;i<a.row;i++) if(maxitem<a(i,j)) maxitem=a(i,j); p.data[j]=maxitem; } return p; }else{ Matrix p(a.row,1); double maxitem=DBL_MIN; for (int i=0;i<a.row;i++) { maxitem=DBL_MIN; for (int j=0;j<a.column;j++) if(maxitem<a(i,j)) maxitem=a(i,j); p.data[i]=maxitem; } return p; } }}
max函数的使用测试
#include "Matlab2c.h"#pragma comment(lib,"Matlab2c.lib") using namespace Matlab2c;int main(){ double a[]={1,2,3,4,5,6}; Matrix aa=Matrix(1,6,a); Matrix bb=Matrix(2,3,a); Matrix cc=Matlab2c::max(aa); cout<<cc.toString()<<endl; Matrix dd=Matlab2c::max(bb,1); cout<<dd.toString()<<endl; Matrix ee=Matlab2c::max(bb,2); cout<<ee.toString()<<endl; system("pause"); return 0;}
阅读全文
2 0
- matlab2c使用c++实现matlab函数系列教程-max函数
- 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函数
- IntelliJ IDEA 2016注册方法和注册码
- Thinkphp处理ueditor插入转义字符到数据库的方法
- 函数式与响应式的领域模型<Functional and Reactive Domain Modeling>(三)
- 170
- 内核基础层提供的服务---软中断和tasklet 、 工作队列
- matlab2c使用c++实现matlab函数系列教程-max函数
- BZOJ3259(莫比乌斯反演 + 树状数组 + 离散处理 + 极性函数)
- matlab2c使用c++实现matlab函数系列教程-min函数
- sublime的下载地址及Package Control的安装
- jquery-DOM操作
- 获取本机IP
- matlab2c使用c++实现matlab函数系列教程-mean函数
- Kafka 实例
- matlab2c使用c++实现matlab函数系列教程-median函数