选择要绘制的特定点

时间:2021-05-05 11:15:20

I am plotting number of correct and functioning sensors at each 100 runs.

我正在每100次运行中绘制正确且功能正常的传感器数量。

I will get the following plot: 选择要绘制的特定点

我将得到以下情节:

The 100 readings taken for each of the runs is somewhat confusing. How can I make matlab plot

每次运行所获得的100个读数有些令人困惑。我怎样才能制作matlab图

  1. At every 5 values (5,15,20....)

    每5个值(5,15,20 ....)

  2. The average of 5 runs so that number of plots will be 100/5.

    平均5次运行,因此图的数量将是100/5。

can you help in these two cases thanks

你能帮助这两个案件谢谢吗?

if round=10 in the original case will have 10 bars,

如果在原始情况下圆= 10将有10个条,

With the formula given by @Richante data_to_plot = data(1:5:end); will have 2 bars. Great but when I plot will get values at Round 1 and 2. How to display that these are for rounds 1 and 5?

使用@Richante给出的公式data_to_plot = data(1:5:end);将有2个酒吧。很棒但是当我的情节将在第1轮和第2轮获得值。如何显示这些是第1轮和第5轮?

1 个解决方案

#1


2  

You can plot every 5th item by slicing the array:

您可以通过切割数组来绘制每第5个项目:

data = %1-by-100 array
data_to_plot = data(1:5:end);

To plot the average of 5 runs, you could do a for-loop:

要绘制5次运行的平均值,您可以执行for循环:

data_to_plot = zeros(1, 20);
for i=1:20
  data_to_plot = mean(data((i-1)*5:i*5));
end

Or a neat way is to reshape the array into a 5-by-20 matrix and take the mean in the first dimension:

或者一个简洁的方法是将数组重新整形为5乘20的矩阵并取第一维中的均值:

data_to_plot = mean(reshape(data, 5, 20));

#1


2  

You can plot every 5th item by slicing the array:

您可以通过切割数组来绘制每第5个项目:

data = %1-by-100 array
data_to_plot = data(1:5:end);

To plot the average of 5 runs, you could do a for-loop:

要绘制5次运行的平均值,您可以执行for循环:

data_to_plot = zeros(1, 20);
for i=1:20
  data_to_plot = mean(data((i-1)*5:i*5));
end

Or a neat way is to reshape the array into a 5-by-20 matrix and take the mean in the first dimension:

或者一个简洁的方法是将数组重新整形为5乘20的矩阵并取第一维中的均值:

data_to_plot = mean(reshape(data, 5, 20));