matlab2c使用c++实现matlab函数系列教程-load函数
来源:互联网 发布:赵薇事件公知 编辑:程序博客网 时间:2024/06/08 11:36
全栈工程师开发手册 (作者:栾鹏)
matlab2c动态链接库下载
matlab库函数大全
matlab2c基础教程
matlab2c开发全解教程
matlab2c调用方法:
1、下载matlab2c动态链接库
2、将matlab2c.dll、matlab2c.lib和matlab2c.h放到项目头文件目录下
3、在cpp文件中引入下面的代码
#include "Matlab2c.h"#pragma comment(lib,"Matlab2c.lib") using namespace Matlab2c;
matlab中load函数简介
1、load函数:
从文件中读取矩阵数据
2、用法说明
A= load (‘e:\123.txt’) 从文件123.txt中读取矩阵
load的c++源码实现
从文件中加载数据
文件内容为矩阵数组形式,元素间通过空格间隔
Matrix Matlab2c::load(string path){ std::ifstream fin(path, std::ios::in); char line[1024]={0}; string x="0"; vector<vector<double>> alldata; while(fin.getline(line, sizeof(line),'\n')) { vector<double> onerow; std::stringstream word(line); while(word>>x) { onerow.push_back(std::stod(x)); } if (onerow.size()!=0) { alldata.push_back(onerow); } } fin.close(); Matrix p(alldata); return p;}
load函数的使用测试
数据文件data.txt
11 22 33 44
22 33 44 55
33 44 55 66
示例代码:
#include "Matlab2c.h"#pragma comment(lib,"Matlab2c.lib") using namespace Matlab2c;int main(){ Matrix bb=Matlab2c::load("data.txt"); cout<<bb.toString()<<endl; system("pause"); return 0;}
阅读全文
1 0
- matlab2c使用c++实现matlab函数系列教程-load函数
- 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和mybatis整合
- 博客怎么写?
- locust
- 解决-maven项目,jsp引入包不起作用
- matlab2c使用c++实现matlab函数系列教程-load函数
- nginx服务器日志介绍与按天分割
- Hibernate的一对一映射
- 欢聚时代2017校招笔试题目(JAVA基础类)A卷--3
- 顺序表应用3:元素位置互换之移位算法
- 深入理解计算机系统(1.1)------Hello World 是如何运行的
- Zookeeper的可靠性是怎么保证的?
- [NOI 2008] 志愿者招募
- 浅谈继承和多态