MATLAB: Any other ways to program tan(x) between [-3*pi/2 to 3*pi/2])

tan(x)

Hello!
I write down the code for the tan(x) between [-3*pi/2 to 3*pi/2]), but I want to reduce it, or doing it in another way. Any ideas?
x1=-(3*pi/2)+0.01:0.01:-(pi/2)-0.01;
plot(x1,tan(x1),'r','linewidth',2.5)
hold on
x2=-(pi/2)+0.01:0.01:(pi/2)-0.01;
plot(x2,tan(x2),'r','linewidth',2.5)
x3=(pi/2)+0.01:0.01:(3*pi/2)-0.01;
plot(x3,tan(x3),'r','linewidth',2.5)
hold off

Best Answer

x = -3*pi/2 + .1 : 0.1 : 3*pi/2 - 0.1;
y = tan(x);
plot(x, tan(x), 'r','linewidth',2);
grid on;