plotting tan(x) - basic student's question
Ältere Kommentare anzeigen
I am new to matlab and have been trying to plot basic things.
I have sucessfully managed to plot sin(x) by doing the following:
x = -2*pi:pi/100:2*pi; y = sin(x); plot(x,y)
However, when I replace the sin(x) by tan(x), the plot does not come out right. I can't figure out why this is. On the other hand I have managed to plot tan(x) using ezplot...
Akzeptierte Antwort
Weitere Antworten (3)
Wayne King
am 27 Feb. 2014
Bearbeitet: Wayne King
am 27 Feb. 2014
tan(x) is periodic with period pi and "blows up" at odd multiples of pi/2 so why not just plot one period?
dx = 0.01;
x = -pi/2+dx:pi/100:pi/2-dx;
y = tan(x);
plot(x,y)
by increasing dx, you'll get a better visual because the value near +/- pi/2 grows in magnitude so quickly, the plot becomes dominated by the large negative and positive values,
dx = 0.1;
x = -pi/2+dx:pi/100:pi/2-dx;
y = tan(x);
plot(x,y)
hai yang
am 10 Jun. 2018
1 Stimme
ezplot('tan(x)')
does the work very well
1 Kommentar
Adil Rashid
am 26 Mär. 2020
Greatest answer
pulkit verma
am 28 Aug. 2021
0 Stimmen
ezplot("tan(x)")
Kategorien
Mehr zu Line Plots finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!