matlab2c使用c++实现matlab函数系列教程-normrnd函数
来源:互联网 发布:淘宝上如何收烟丝 编辑:程序博客网 时间:2024/05/13 19:29
全栈工程师开发手册 (作者:栾鹏)
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中normrnd函数简介
1、normrnd函数:
生成正态分布矩阵
2、用法说明
R = normrnd(MU,SIGMA) %返回均值为MU,标准差为SIGMA的正态分布的随机数据,R可以是向量或矩阵.
R = normrnd(MU,SIGMA,m) %m指定随机数的个数,与R同维数
R = normrnd(MU,SIGMA,m,n) %m,n分别表示R的行数和列数
normrnd的c++源码实现
生成正态分布矩阵
输入正态分布的两个参数,均值和标准差,以及行数(默认为1),列数(默认为1)
输出正态分布数、向量或矩阵
函数声明Matrix normrnd(double aver ,double sigma,int rowsnum=1,int columnsnum=1);函数定义Matrix Matlab2c::normrnd(double aver ,double sigma,int row,int column){ double x,dScope,y,fengzhi; int i,j; Matrix p(row,column); srand((unsigned)time(0)); for (i=0;i<p.row;i++) { for (j=0;j<p.column;j++) { do { x=((double)rand()/RAND_MAX)*6*sigma+aver-3*sigma; //产生均值正负3sigma的值, y = 1.0/(std::sqrt(2*PI)*sigma)*std::exp(-1*(x-aver)*(x-aver)/(2*sigma*sigma)); fengzhi = 1.0/(std::sqrt(2*PI)*sigma); dScope = ((double)rand()/RAND_MAX)*fengzhi; }while( dScope > y); p(i,j)=x; } } return p;}
normrnd函数的使用测试
#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 cc=Matlab2c::normrnd(2,5,3,3); cout<<cc.toString()<<endl; system("pause"); return 0;}
阅读全文
2 0
- matlab2c使用c++实现matlab函数系列教程-normrnd函数
- matlab2c使用c++实现matlab函数系列教程-normrnd函数
- 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函数
- 等比数列求和
- 襄阳森林、湿地公园开发建设
- Retrofit2.0源码解析
- matlab2c使用c++实现matlab函数系列教程-awgn函数
- uplodify 上传插件与My97时间插件综合应用(时间判断,表单button提交)
- matlab2c使用c++实现matlab函数系列教程-normrnd函数
- 计算机网络基础(二)
- Hessian初步理解
- matlab2c使用c++实现matlab函数系列教程-nchoosek函数
- A
- matlab2c使用c++实现matlab函数系列教程-sawtooth函数
- 第一次向GitHub提交代码失败
- 【区块链系列1】区块链科普
- 每日小记2