[英]Read MATLAB dataset without headers
I have a MATLAB dataset and I want to extract the numbers only without reading the headers. 我有一个MATLAB数据集,我想只提取数字而不读取标题。 Is there any straightforward way to do that? 有没有直截了当的方法呢?
I HAVE THIS: 我有这个:
MeanOfTrainingMSE MeanOfTestMSE
Naive Regression 26.291 26.327
Linear Regression (attribute 400) 1.2466 1.2592
Linear Regression (attribute 357) 1.214 1.2356
Linear Regression (attribute 440) 1.1494 1.1562
Linear Regression (attribute 404) 1.0072 1.0111
Linear Regression (attribute 238) 0.92402 0.93002
Linear Regression (attribute 473) 0.89838 0.90397
Linear Regression (all attributes) 4.1155e-07 877.58
Ridge Regression 2.9044e-10 0.2533
Kernel Ridge Regression 1054.8 1023.2
I WANT TO GET THIS: 我想得到这个:
26.291 26.327
1.2466 1.2592
1.214 1.2356
1.1494 1.1562
1.0072 1.0111
0.92402 0.93002
0.89838 0.90397
4.1155e-07 877.58
2.9044e-10 0.2533
1054.8 1023.2
If your dataset is named aFile
, for example, you can retrieve the values of those columns of interest by 例如,如果您的数据集名为aFile
,则可以检索这些感兴趣的列的值
>> X=[aFile.MeanOfTrainingMSE aFile.MeanOfTestMSE]
Edit to answer your comment: 编辑以回答您的评论:
There may be a better way, but you could do something like: 可能有更好的方法,但你可以这样做:
>> m=length(aFile.Properties.ObsNames);
>> n=length(aFile.Properties.VarNames);
>> data=ones(m,n);
>> names=aFile.Properties.VarNames;
>> for a =1:n
data(:,a)=aFile.(names{a});
end
Of course this assumes each column in your data is numeric. 当然,这假设数据中的每一列都是数字。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.