小编Rod*_*eis的帖子

Matlab(2008a-32bit)单精度bug

如果我使用值进行单个精度操作,它将给出以8结尾的结果:

>> single(single(6.500001e+02)*single(-64.1775131)*single(0.65)*single(2))
ans =   -5.4230008e+004
Run Code Online (Sandbox Code Playgroud)

然后我使用双精度进行任何操作,并且操作与之前相同,使用单精度,结果将与我第一次运行时不同:

>> double(6.5000012e+02)*double(-64.1775131)*double(0.65)*double(2)
ans =   -5.423000858119204e+004

>> single(single(6.500001e+02)*single(-64.1775131)*single(0.65)*single(2))
ans =  -5.4230004e+004
Run Code Online (Sandbox Code Playgroud)

这个问题发生在Matlab 2008a 32位.这在Matlab 2012b 64位中不是问题.

有关如何避免这个问题的任何想法?

谢谢.

matlab

5
推荐指数
1
解决办法
116
查看次数

重塑表的性能

我怎样才能从这样的表格中走出来:

  ID  Day  car_id value
  1   1    1      0
  1   1    2      4
  1   2    1      1
  1   3    2      0
  2   1    3      0
  2   2    3      2
  2   3    3      0
  ...
Run Code Online (Sandbox Code Playgroud)

对于这样的人?我尝试过使用reshape2包中的dcast.它运行正常,但由于数据集非常大,因此速度有点慢.还有另一种方法可以更快地完成吗?

  ID  Day  c_id1 c_id2 c_id3 
  1   1    0      4    0   
  1   2    1      0    0
  1   3    0      0    0
  2   1    0      0    0
  2   2    0      0    3
  2   3    0      0    0
Run Code Online (Sandbox Code Playgroud)

谢谢!

r reshape tapply reshape2

2
推荐指数
1
解决办法
455
查看次数

标签 统计

matlab ×1

r ×1

reshape ×1

reshape2 ×1

tapply ×1