MATLAB: How to plot this function

parabolaplotplotting

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.

Best Answer

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