Adding an extra legend entry
35 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Vaishnavi Thavarajah
le 18 Avr 2022
Commenté : Vaishnavi Thavarajah
le 18 Avr 2022
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 commentaires
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Legend dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!