MATLAB: How to plot the data and superimpose the mean of the data

plottingunit conversion

I am required to plot 20 second data of my veleocity. then i need to superimpose the mean of the velocity. Can somebody look into my codes. I dont know how to convert the velocity in Hz into second. The velocity is measure with a device that collect data 100 times in a second.
here is my code
U20=U(1:2000,:); % Selection of 20 seconds of data
Usec=U20/100; % 1 second =100 Hz (I think i am making mistake here)
plot(Usec); % ploting of instantinous velocity
Umean=mean(Usec); % Mean of the sample
hold on
plot(Umean,'-','LineWidth',1); % Superimposing the mean velocity
xlabel('sample data length');
ylabel('Stream wise velocity');
The graph should look like the attached picture where U is the mean and U' is the instantaneous velocity.
many thanks

Best Answer

% Generating some sample data
t=linspace(0,2*pi,100);
U=sin(t);
% Ploting velocity
plot(t, U);
axis tight
hold on
% Now plotting the mean value.
Umean = mean(U);
line(xlim, [Umean,Umean],'Color','r');