Adding an extra legend entry
42 次查看(过去 30 天)
显示 更早的评论
I need to display the mean value of the plot in the legend saying mean = 'c4timeavg(1)' m/s. Is there a way of adding extra legend entries, so that the final plot looks really nice and organised?
clear variables; clc
load('c4.dat') % loading c4 data
g = 9.81;
rho = 1000;
dt = 0.005; % corresponding to 200 Hz sampling frequency etc.
c4uy = c4(:,4); % storing the y-component of the velocity at point C4
c4time = dt*c4(:,1); % storing the time values at which the corresponding values of velocity are measured
c4interval = [c4time(1) c4time(end)]; % storing the time interval (30s) in an array for plotting later
c4timeavg = [mean(c4uy) mean(c4uy)]; % calculating and storing the mean of y-component of the velocity at c4 for plotting
%% plotting the velocities at the y-component and the mean of the y-component of the velocities at c4.
figure
hold on
grid minor
plot (c4time, c4uy); % plotting the y-component at c4
plot (c4interval, c4timeavg, '-k', 'LineWidth', 1); % plotting the mean of the y-component for 30s
xlabel('t (s)')
ylabel('v (m/s)')
title('U2 at point C4')
xlim(c4interval)
legend('raw data', 'time-average velocity')
hold off
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Legend 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!