how to plot more than one function with out using fplot?

12 vues (au cours des 30 derniers jours)
Katie Norbury
Katie Norbury le 4 Août 2021
Réponse apportée : KSSV le 4 Août 2021
how do i plot:
f(x)=(x-3)/(x-2)
g(x)=(2x-3)/(x-1)
with an x-axis ranging from -4 to 4 and a y-axis ranging from -10 to 10
this is what ive attempted but the grapgh isnt looking like what it should
x = linspace(-4,4,1000);
%functions
fx = ((x-3)./(x-2));
gx = ((2*x-3)./(x-1));
%plotting
plot(x,fx,'r',x,gx,'g')

Réponses (1)

KSSV
KSSV le 4 Août 2021
You have to limit the y-axes if you want to limit to desired ranges. Read about ylim.
x = linspace(-4,4,1000);
%functions
fx = ((x-3)./(x-2));
gx = ((2*x-3)./(x-1));
%plotting
plot(x,fx,'r',x,gx,'g')
ylim([-10 +10])

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by