How do I plot blue asterisks on the x and y intercepts of a linear function on a 2D graph?
2 views (last 30 days)
Show older comments
%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 Comments
Answers (1)
Chunru
on 1 Sep 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 Comments
See Also
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!