Info

This question is closed. Reopen it to edit or answer.

how can i plot the mean of a series of closed 2d loops?

1 view (last 30 days)
I am trying to get the mean value of a series of loops. Some are elliptic, some are shaped like an eight figure
I have two vectors: of around C_l = 1*3000 and alpha = 1*3000 this differs from case to case. I want a on the x axis and C_l on the y axis. One loop is around 60 points, so that's about 50 loops. I want to plot a single loop that takes the mean of all the 50 loops.
if true
plot(ao(1,1:ms),Clp(1,1:ms),'r','LineWidth',1)
end
Here ms is the number of entries of the vectors.

Answers (1)

Star Strider
Star Strider on 13 Mar 2014
I suggest something like this:
% Create some data:
v = 0:599;
ao = sin(2*pi*v/60 + pi/6) + 0.25*(rand(size(v))-0.5);
C_I = cos(2*pi*v/60) + 0.25*(rand(size(v))-0.5);
% Create matrices:
nrow = 60;
ao_m = reshape(ao, nrow, fix(numel(ao)/nrow));
C_I_m = reshape(C_I, nrow, fix(numel(C_I)/nrow));
% Take row means:
mn_ao = mean(ao_m,2);
mn_C_I = mean(C_I_m,2);
% Plot data and means:
figure(1)
plot(ao, C_I, '-r')
hold on
plot(mn_ao, mn_C_I, '-b', 'LineWidth',2)
hold off
grid
NOTE: You may have to trim your vectors (that must be integer multiples of nrow) to make the reshape function work. This code also assumes that your original data are row vectors.

Community Treasure Hunt

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

Start Hunting!