阿蓉之从零开始的【VC++】——数据写入excel csv文件+ MATLAB数据统计图

tech2022-09-13  109

本来是要直接可视化出数据的统计直方图的,可是不大会用c++搞,所以打算将数据保存到表格中,之后用matlab搞一下直方图,果然,vegetable chicken 有自己的办法~

        


将文件写入csv文件:

参考:https://blog.csdn.net/u010325168/article/details/53005159

https://blog.csdn.net/yz2zcx/article/details/100567312

#include <iostream> #include <fstream> #include <string> using namespace std; int main() { ofstream oFile; oFile.open("test.csv",ios::out|ios::trunc); oFile<<"属性1"<<","<<"属性2"<<","<<"结果1"<<","<<"结果2"<<endl; oFile<<"010101"<<","<<"1 2 3"<<","<<"32.2 112.3;23.12 23.22;23.14 23.45"<<","<<"1"<<endl; oFile.close(); }

在MATLAB显示数据的各种统计图:

参考:MATLAB 可视化之统计图:https://blog.csdn.net/baishuo8/article/details/81317521

https://blog.csdn.net/dujiahei/article/details/90763076

matlab读取cvs文件的几种方法:https://blog.csdn.net/u014410989/article/details/79064252

x= csvread('dragon_orig.csv'); %第3列 xx=x(:,3); nbins=1000;%bin的个数 h=histogram(xx,nbins)%统计图 y=[]; %每个bin的边界值 y(:,1)=h.BinEdges(); y(1,2)=0; y(1,3)=0; %每个Bin中数据的个数 y(2:end,2)=h.Values(); %累加求和 y(2:end,3)=cumsum(y(2:end,2)); title = {'edge','count','point_sum'}; yy=[title,y];%加title file=xlswrite('dragon_hist.xls',yy);

最新回复(0)