• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Linux中Matlab保存多个数据到同一个文件当中

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
% load pyrim
% NumTrain = 50;

% load machine
%NumTrain = 150;

% load housing
% NumTrain = 300;

% load abalone
% NumTrain = 1000;

% load bank32nh
% NumTrain = 3000;

% load cpuact
% NumTrain = 4000;

%  load calhousing
% NumTrain = 5000;

%  load census
% NumTrain = 6000;



  load calhousing
  path= '/root/orca-master0/orca-master/';
  name='CaliforniaScaling';
  NumTrainforScaling =  [100:100:900,1000:1000:10000] ;
 for i = 1:length(NumTrainforScaling)
NumTrain = NumTrainforScaling(i);

k=i;
% for k = 1:10
n = size(X,1);
 NumTest = n - NumTrain;
% id = randperm(n);
id = id0(k,:);
traindata = X(id(1:NumTrain),:);
targets = y(id(1:NumTrain));
TestData = X(id(NumTrain+1:n),:);
TestTargets = y(id(NumTrain+1:n));

X1=[targets-1,traindata];
n0 = size(X1,2);
X1 = sortrows(X1,1);

X2=[TestTargets-1,TestData];

% traindata = X1(:,1:end-1);
% targets = X1(:,end);

% X1=[traindata,targets];

% fname1 = strcat('C:\Users\hd\Desktop\machine\mytask_train.',num2str(k-1));
% fname2 = strcat('C:\Users\hd\Desktop\machine\mytask_test.',num2str(k-1));

% fname1 = strcat('C:\Users\hd\Desktop\housing\mytask_train.',num2str(k-1));
% fname2 = strcat('C:\Users\hd\Desktop\housing\mytask_test.',num2str(k-1));

% fname1 = strcat('C:\Users\hd\Desktop\abalone\mytask_train.',num2str(k-1));
% fname2 = strcat('C:\Users\hd\Desktop\abalone\mytask_test.',num2str(k-1));

% fname1 = strcat('C:\Users\hd\Desktop\bank32nh\mytask_train.',num2str(k-1));
% fname2 = strcat('C:\Users\hd\Desktop\bank32nh\mytask_test.',num2str(k-1));

% fname1 = strcat('C:\Users\hd\Desktop\cpuact\mytask_train.',num2str(k-1));
% fname2 = strcat('C:\Users\hd\Desktop\cpuact\mytask_test.',num2str(k-1));

%  fname1 = strcat('C:\Users\hd\Desktop\calhousing\mytask_train.',num2str(k-1));
%  fname2 = strcat('C:\Users\hd\Desktop\calhousing\mytask_test.',num2str(k-1));
 
%  fname1 = strcat('C:\Users\hd\Desktop\census\mytask_train.',num2str(k-1));
%  fname2 = strcat('C:\Users\hd\Desktop\census\mytask_test.',num2str(k-1));
path =  '/root/nnrank1.2/data/';
fname1 = strcat(path,name,'/mytask_train.',num2str(k-1));
fname2 = strcat(path,name,'/mytask_test.',num2str(k-1));
fname3 = strcat(path,name,'/mytask_targets.',num2str(k-1));

%  fname1 = strcat('C:\Users\hd\Desktop\scalecalhousing\mytask_train.',num2str(k-1));
% libsvmwrite(fname1, targets, sparse(traindata));


% save(fname1,'X1','-ascii')
% %save(fname2,'X2','-ascii')
%  save(fname2,'TestData','-ascii')
%  save(fname3,'TestTargets','-ascii')
 
 
 TrainNNOP{1} = size(X1,2)-1;
 TrainNNOP{2} = [5, 0:4];
 TrainNNOP{3} = size(X1,1);
 TrainNNOP{4} = X1;
 
 TestNNOP{1} = size(X2,2)-1;
 TestNNOP{2} = [5, 0:4];
 TestNNOP{3} = size(X2,1);
 TestNNOP{4} = X2;
 
 for j = 1:4
     dlmwrite(fname1,TrainNNOP{j},'delimiter', ' ','-append'); 
%      dlmwrite(fname2,TestNNOP{j},'delimiter', '\t');
 end

% libsvmwrite(fname1, targets, sparse(traindata));
% libsvmwrite(fname2, TestTargets, sparse(TestData));

% end
  end

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
深入Delphi--Windows消息机制发布时间:2022-07-18
下一篇:
Delphi-Windows自动计划任务与ParamStr详解发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap