同一个 table 中的 Matlab 多个类型数字

Matlab multiple type numbers in same table

我想把这两种类型的数字放在一个中table。一列的索引为 int64,另一列的值为 single....

1359410513
1359410521
1359410529
1359410536
1359410542   
1359410548
1359410554

40.299999
39.099998
37.900002
36.799999
35.700001
34.700001
33.599998

但是当我把它们放在一起时,值是:2000 X 2 int64。所以所有的值都在点之后被切掉。像这样:

40
39
38
37
36
35
34

谁能帮我解决这个问题?如何将它们合二为一 table。谢谢

这是一个示例代码...所以基本思想是当一列是 int64 时,另一列是单一的。结果总是将其中之一转换为相同的类型,结果失去分辨率:

value1=int64(sort((1359418241-20)*rand(30,1)+20,'ascend'));
value2=single(rand(30,1));
field1='index';
field2='value';
s=struct(field1,value1,field2,value2)

data_table=struct2table(s);
data_cell=table2cell(data_table);
data_mat = cell2mat(data_cell(:, 1));
data_mat1 = cell2mat(data_cell(:, 2));

start_time=701146404;
end_time=1221278149;
%Find the neighbour points
thresholdpoint_start = find(data_mat > start_time, 1)-1;
thresholdpoint_end = find(data_mat >= end_time, 1);
for i=1:thresholdpoint_end-thresholdpoint_start+1 
    data_ss(i,2)=single(data_mat1(thresholdpoint_start+i-1,1));
    data_ss(i,1)=data_mat(thresholdpoint_start+i-1,1);


end 

具有不同数据类型的数据的正确结构是元胞数组。没有办法用标准数组(矩阵)做同样的事情。但是,您可以做的是将所有数据放入一个 double 数组中,该数组具有足够的精度来正确表示您的整数。