在数组中查找索引,使用索引作为查找,绘制w / r / t时间

时间:2013-02-03 06:57:58

标签: matlab octave

我希望在数组中找到n个最大值,然后将这些找到的值的索引用作查找到另一个表示时间的数组中。但我想知道如果我想要时间显示为连续变量我可以如何绘制。我需要将数据清零吗?这对我的用例来说并不是优选的,因为我希望节省内存。

假设我有数组A,这是我在寻找最大值的地方。然后我有数组T,它代表时间戳。我希望我的情节显示连续时间,而情节()不喜欢不同大小的参数。大多数人如何处理这个?

这是我到目前为止所得到的:

numtofind = 4;
A = m{:,10};
T = ((m{:,4} *  3600.0) + (m{:,5} * 60.0) + m{:,6});

[sorted, sortindex] = sort(A(:), 'descend');
maxvalues = sorted(1:numtofind);
maxindex = sortindex(1:numtofind);
corresponding_timestamps = T(maxindex);

%here i plot the max values against time/corresponding timestamps, 
%but i want to place them in the right timestamp and display time as continuous 
%rather than the filtered set:
plot(time_values, maxvalues);

1 个答案:

答案 0 :(得分:1)

当你说“时间连续”时,你是说你想要时间从最小到最大?如果是这样,您只需对corresponding_timestamps进行排序并使用它来重新排序maxvalues。即使你不这样做,你仍然可以plot(time_values, maxvalues, '.')得到一个散点图,它不会弄乱你的图表。

相关问题