# showing the distance between the two plots on two curves at regular intervals on the same plot

9 visualizaciones (últimos 30 días)
AJAY CHANDRA DORAGARI el 14 de Jul. de 2020
for example two lines are plotted with equation line 1 x=t^2 and y=(0.5*(t^2))// path and line 2 y=2x+6 // which is boundary i want them within the boundary so discared other points
i want two display the distance between two lines at regular intervals on the same plot indicating the distance between them
t=0:0.2:10;
for k=1:length(t)
x(k)=t(k).^2;
y(k)=0.5*(t(k).^2)+10;
m(k)=(2*x(k))+6;
end
c=y<=m
l=y(c);
g=x(c);
plot(g,l)
hold
plot(x,m)
legend('path','boundary')
xlabel('x-axis')
ylabel('y-axis')
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Vladimir Sovkov el 14 de Jul. de 2020
t=0:0.2:10;
% avoid loops wherenever possible, use element-wise operations instead
x=t.^2;
y=0.5*x+10; % the same as "y=0.5*t.^2+10;" but faster
m=2*x+6;
%
c=find(y<=m);
plot(x(c),y(c),'.-b',x(c),m(c),'*--r');
legend('path','boundary')
xlabel('x-axis')
ylabel('y-axis')
##### 2 comentariosMostrar NingunoOcultar Ninguno
madhan ravi el 14 de Jul. de 2020
c=find(y<=m); % find is not necessary here
Vladimir Sovkov el 14 de Jul. de 2020
Try the datatips:
t=0:0.2:10;
% avoid loops wherever possible, use element-wise operations instead
x=t.^2;
y=0.5*x+10; % the same as y=0.5*t.^2+10; but faster
m=2*x+6;
c=find(y<=m);
plot(x(c),y(c),'o-b',x(c),m(c),'*--r');
legend('path','boundary')
xlabel('x-axis')
ylabel('y-axis')
%
n=5; % add a datatip to every 5th point
hold on;
cp = plot(x(c),m(c)-y(c),'LineStyle','none');
for k=1:floor(numel(c)/n)
datatip(cp,'DataIndex',k*n+1,'FontSize',8);
end
hold off;

Iniciar sesión para comentar.

### Más respuestas (1)

AJAY CHANDRA DORAGARI el 14 de Jul. de 2020
i want to indicate the distances between the curves/lines at some regular interval say at 10,20,30.. on x-axis within the same graph is there any plotting technique to show them other gtext and inserting arrow at those points
##### 1 comentarioMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos
AJAY CHANDRA DORAGARI el 14 de Jul. de 2020
i used find so that i wanted the points which confined between the boundary line , x-axis and y-axis @madhan ravi

Iniciar sesión para comentar.

### Categorías

Más información sobre Line Plots en Help Center y File Exchange.

### Community Treasure Hunt

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

Start Hunting!

Translated by