How to average a range of output from a graphical equation?

2 次查看(过去 30 天)
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

采纳的回答

Walter Roberson
Walter Roberson 2016-2-26
mask = x >= 3 & x <= 6;
validx = x(mask);
ybar = mean( y(validx) );
plot(validx([1 end]), [ybar ybar], 'k')

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Audio I/O and Waveform Generation 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by