fplot not plotting an exponential function

Viewed 87

I'm trying to plot this function 0.5*sinc(n/2)*e^(0.5*j*n*pi*t) using this code:

n = 1;
x2t = @(t) 0.5*sinc(n/2)* exp(sqrt(-1)*n*pi*0.5*t);
fplot(x2t);

but I only get blank results, what's the problem?

1 Answers

Your function produces a complex result, and fplot does not plot that properly. Instead, you could plot the real and imaginary components separately:

n = 1;
x2t = @(t) 0.5*sin(n/2)/(n/2) * exp(1i*n*pi*0.5*t);
fplot(@(t)real(x2t(t)));
hold on
fplot(@(t)imag(x2t(t)));

Notice that I replaced sinc(n/2) with sin(n/2)/(n/2), since I don't have the sinc function in my version of MATLAB. I also replaced sqrt(-1) with the simpler 1i.

Related