Plot questions (variables at legend, labeling a marker)
Mostrar comentarios más antiguos
hi , so i got two questions. i made a function to find an intersection between two lines (y=x+c) and then plots the lines. Now i have two questions, 1)how do i make the leggend accept the input variables to display. 2) how do i label the intersection point on the plot itself?
function p=inters(v1,v2) %v1,v2 are lines inputed as vectors i.e v1=[2 -1] v2=[-3,1] (y=2x-1,y=-3x+1)
xt=v1(1)-(v2(1));
c=v1(2)-(v2(2));
x0=(-c)/xt;
y0=v1(1)*x0+v1(2);
p=[x0,y0];
x=x0-5:x0+5;
xmarkers=x0;
ymarkers=y0;
plot(x,polyval(v1,x),'b',xmarkers,ymarkers,'b*')
hold
plot(x,polyval(v2,x),'g')
i need the legend to change depending on the input to the fuction v1 and v2 so me typing legend y=2x-1 wont work...
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Legend en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!