MATLAB 和 armadillo 数据转换

摘要:
iostream>#包括<intmain(){arma:“x=”&lt:“A=”<&lt:A<“v=”&lt:strigname=“test_mat.dat”;test_mat.load(名称;matest_mat;raw_ascii);test_mat
#include<iostream>
#include<armadillo>

int D=5;
int M=4;

int main()
{
	arma::fmat x; x.randn(D,1);
	arma::fmat A; A.randn(M,D);
	std::cout<<"x= 
"<<x<<std::endl;
	std::cout<<"A= 
"<<A<<std::endl;

	arma::vec v(10); v={1,2};
	std::cout<<"v= 
"<<v<<std::endl;

	//load mat binary file

	// std::string name="test_mat.dat";
	// arma::mat test_mat;test_mat.load(name, arma::raw_binary);
	// test_mat.print("test_mat");

	//load mat ascii file
	std::string name="matlab_data.dat";
	arma::mat test_mat;
	test_mat.load(name, arma::raw_ascii);
	test_mat.print("test_mat");
	test_mat(0,0)=0.123456789;
	test_mat.raw_print("test_mat");
	auto a_number = 0.12345678987654321;
	std::cout << a_number << std::endl;
	std::streamsize ss = std::cout.precision();
	std::cout << "Default std::cout precision: 
"<<ss<<std::endl;

	return 0;
}
  • test_mat.load(name, arma::raw_ascii)读入的是ASCII文件格式,需要在MATLAB中用dlmwrite保存数据,而不是直接保存成.mat格式。

免责声明:文章转载自《MATLAB 和 armadillo 数据转换》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇C#编程总结(十三)数据压缩使 nodejs 代码 在后端运行(nohup)下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

maven部署命令

参考文档:http://blog.csdn.net/woshixuye/article/details/8133050 http://www.blogjava.net/itvincent/archive/2011/07/13/354243.html maven部署源代码的插件配置(在pom.xml文件中) <build> <plugins...

HTML5新特性之文字转语音

/** * 文字转语音,利用H5的新特性SpeechSynthesisUtterance,speechSynthesis实现 * eg. * const speaker = new Speaker({ text: '这是一条神奇的天路啊' }); * speaker.start(); // 开时播放 * setTimeout((...

基于WPF系统框架设计(6)-整合MVVM框架(Prism)

应用场景 我们基础的框架已经搭建起来了,现在整合MVVM框架Prism,在ViewModel做一些逻辑处理,真正把界面设计分离出来。 这样方便我们系统开发分工合作,同时提高系统可维护性和灵活性。 具体的Prism安装和Microsoft.Practices.Prism.dll获取,在这个网址:http://compositewpf.codeplex.com...

ant design select 坑总结

1、保持Option的value和select绑定的value一致,这样在select框中显示的才是Option中的节点文本label 2、labelInValue属性可以使选中项的文本label包装到value中传递给onChange,此时value是一个对象,注意用了labelInValue就不能用value <Select...

Laravel 5.2 三、中间件、视图与 Blade 模板引擎

一、中间件 Laravel 的 HTTP 中间件提供了对路由的一层过滤和保护。下面模拟一下用中间件验证后台登录。 1. 创建中间件 cmd 窗口进入项目目录,使用 artisan 命令创建 php artisan make:middleware AdminLoginVerify 这将在 app/Http/Middleware 目录创建中间件 AdminLo...

ADB调试技巧记录

一.多个在线设备adb 1. 通过adb devices命令获取所有online设备的serial number。 C:UsersAdministrator>adb devices List of devices attachedemulator-5554   deviceSH0A6PL00243    device 上面表示,当前有两个设备onli...