Taking mean of only specific values in column vector.

1 次查看(过去 30 天)
Hi , i have a column vector with 60 rows and 1 column as shown below. I want to take mean of only the values i.e 0.13 Can anybody suggest me how can i do that in MATLAB
[0.13
0.26
0.39
0.52
0.65
0.13
0.26
0.39
0.52
0.13
0.26
0.39
0.13
0.26
0.13
0.13
0.26
0.39
0.52
0.65
0.13
0.26
0.39
0.52
0.13
0.26
0.39
0.13
0.26
0.13
0.13
0.26
0.39
0.52
0.65
0.13
0.26
0.39
0.52
0.13
0.26
0.39
0.13
0.26
0.13
0.13
0.26
0.39
0.52
0.65
0.13
0.26
0.39
0.52
0.13
0.26
0.39
0.13
0.26
0.13]
Thank you
  19 个评论
Image Analyst
Image Analyst 2018-10-11
Ahmad, I know. And I gave you a complete turnkey solution below. Did you try/see it?
Ahmad Bilal
Ahmad Bilal 2018-10-11
I have tried it. It works perfectly fine . Now I want to display this point in my plot as i mentioned below. can you help me in this regard

请先登录,再进行评论。

采纳的回答

Image Analyst
Image Analyst 2018-10-11
Try this:
fileName = 'Test Excel file Mean and std.xlsx';
data = xlsread(fileName)
rows = ismembertol(data(:, 1), 0.13, 0.001) % Rows where column 1 = 0.13
column2 = data(:, 2);
theMean = mean(column2(rows))
  10 个评论
Ahmad Bilal
Ahmad Bilal 2018-10-13
can you help me here with code snippet based on above mentioned variable in code uptil now I have the folllowing code as follows :
dataset = xlsread('Test Excel file Mean and std.xlsx');
x = dataset(:, 1);
y = dataset(:, 2);
scatter(x,y,'*b');
grid on
a = ismembertol(dataset(:, 1), 0.13, 0.001); % Rows where column
1 = 0.13
b = ismembertol(dataset(:, 1), 0.26, 0.001); % Rows where column
1 = 0.26
c = ismembertol(dataset(:, 1), 0.39, 0.001); % Rows where column
1 = 0.39
d = ismembertol(dataset(:, 1), 0.52, 0.001); % Rows where column
1 = 0.52
e = ismembertol(dataset(:, 1), 0.65, 0.001); % Rows where column
1 = 0.65
values = [x y];
theMean1 = mean(y(a));
theMean2 = mean(y(b));
theMean3 = mean(y(c));
theMean4 = mean(y(d));
theMean5 = mean(y(e));
hold all;
plot(0.13, theMean1, 'rs','MarkerFaceColor','r','MarkerSize',10);
plot(0.26, theMean2, 'rs','MarkerFaceColor','r','MarkerSize',10);
plot(0.39, theMean3, 'rs','MarkerFaceColor','r','MarkerSize',10);
plot(0.52, theMean4, 'rs','MarkerFaceColor','r','MarkerSize',10);
plot(0.65, theMean5, 'rs','MarkerFaceColor','r','MarkerSize',10);
% Here I want to use error bar command or box plot command to display error from mean values to each blue points for each corresponding x =0.13 0.26 and so on
xlabel('distance d b/w mic pairs[cm]');
ylabel('\phi_r_a_t_i_o');
title('Relationship between \phi ratio and distance between Mic
Pairs for Array 3');

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Bar Plots 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by