为每个X绘制两个Y的多个值

时间:2015-06-01 16:40:19

标签: arrays matlab plot cells

UPDATE
   foundation-restore.archive,    foundation.archive   
SET
   foundation-restore.archive.FName = foundation.archive.FName  
WHERE
   foundation-restore.archive.user_id = foundation.archive.user_id    
   AND    foundation-restore.archive.user_id > 50    
   AND    foundation-restore.archive.user_id < 266

我有2个阵列。

按值排序,每个单元格包含可能相等的值。

B如上所示。

我想绘制A vs B,但因为我对A的每个元素都有多个值,所以情节非常难看。

有没有办法只为A的每个值保留一个单元格,同时取B中相应单元格的平均值?

例如:

Accessed <current date>
Accessed <current date>
Accessed <current date>
Accessed <current date>
....

1 个答案:

答案 0 :(得分:3)

一种方法 -

model: function() {
  var loadingController = this.controllerFor('loading');
  loadingController.set('progress', 0);

  var promise = new Ember.RSVP.Promise(function(resolve, reject) {
    Ember.run.later(loadingController, 'set', 'progress', 10, 1000);
    Ember.run.later(loadingController, 'set', 'progress', 30, 1300);
    Ember.run.later(loadingController, 'set', 'progress', 50, 1800);
    Ember.run.later(loadingController, 'set', 'progress', 70, 2300);
    Ember.run.later(loadingController, 'set', 'progress', 90, 3300);
    Ember.run.later(loadingController, 'set', 'progress', 100, 4000);
    Ember.run.later(null, resolve, [1,2,3], 4000);
  });

  loadingController.set('promise', promise);
  return promise;
}

更快的替代方案 -

[A1,~,idx] = unique(A,'stable')
B1 = accumarray(idx,B,[],@mean).'

或 -

B1 = (accumarray(idx, B)./accumarray(idx,1)).'

示例运行

输入 -

B1 = (accumarray(idx, B)./histc(idx,1:max(idx))).'

输出 -

>> A,B
A =
        4180        4180        4200        4200        4200        4330
B =
    94   180   120   150   110   160