How do I plot blue asterisks on the x and y intercepts of a linear function on a 2D graph?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
%cartesian plane
p = [-20,20];
q = p-p;
hold on;
plot(p,q);
plot(q,p);
grid on;
% getting the function from the user.
y = input("Introduce a linear function : ");
ezplot(y);
% now how do i plot blue asterisks on the x and y intercepts of the
% function the user just introduced?
0 comentarios
Respuestas (1)
Chunru
el 1 de Sept. de 2022
% getting the function from the user.
% ystr = input("Introduce a linear function a*x+b: ", "s");
ystr ="3*x -6";
y = str2func("@(x)" + ystr);
xintercept = fsolve(y, 0);
yintercept = y(0);
fplot(y)
hold on
xline(0, 'r'); yline(0, 'r');
plot(xintercept, 0, 'b*');
plot(0, yintercept, 'b*');
grid on
0 comentarios
Ver también
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!