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.

 Réponse acceptée

madhan ravi
madhan ravi le 23 Nov 2018
Modifié(e) : madhan ravi le 23 Nov 2018

0 votes

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

2 commentaires

Nicolás Ulmete
Nicolás Ulmete le 23 Nov 2018
Thank you!!!
madhan ravi
madhan ravi le 23 Nov 2018
Anytime :)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Line Plots dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by