Hello,
I'd like to know how to plot the following function, defined by the red lines:
I've previously plotted a rectangle, which is easier because I just draw lines between the different points and that's it, but in this one I don't know how to join the extreme points (1, 1) and (5, 1) with the function y = sqrt(x) instead of a straight line.
Thanks.

 采纳的回答

madhan ravi
madhan ravi 2018-11-23
编辑:madhan ravi 2018-11-23
x=linspace(0,5,1000);
f= sqrt(x);
x0=5;
y0=interp1(x,f,x0);
plot(x,f,'r')
hold on
plot(0:5,zeros(1,6),'r')
plot(5*ones(1,100),linspace(0,y0),'r')
xlim([-2 6])
ylim([-1 3])
Screen Shot 2018-11-23 at 10.17.07 PM.png

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Line Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by