How to average a range of output from a graphical equation?
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
A
le 26 Fév 2016
Réponse apportée : Walter Roberson
le 26 Fév 2016
Hi guys,
I have the following equation and 2dgraph:
x = linspace(0,10);
y = @(x) 2+(2.*log(x));
plot(x,y(x));
hold on
plot(3,y(3),'*',6,y(6),'*');
a) How can I find the average between the two points? b) How can I plot a horizontal bar ( link ) spanning the range of x at the level of average between the two points?
Thank you
0 commentaires
Réponse acceptée
Walter Roberson
le 26 Fév 2016
mask = x >= 3 & x <= 6;
validx = x(mask);
ybar = mean( y(validx) );
plot(validx([1 end]), [ybar ybar], 'k')
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Oceanography and Hydrology 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!