%set up
 x = 1:0.1:10;
 r = sin(x);
 t = 1:91;
 x = mod(t,2) == 0; 
 m_x = mean(r(x));
 m_x2 = mean(-r(~x));
 % plotting
 figure
 plot(t(x),r(x),'b')
 hold on
 plot(t(~x),-r(~x),'r')
 plot(t,ones(length(t),1)*m_x)
 plot(t,ones(length(t),1)*m_x2)
You can do it like this; the only operative part you need to do is:
 m_x = mean(r(x));
 plot(t,ones(length(t),1)*m_x)
Which in your code would like slightly different since you appear to have r as a matrix instead of a vector.


