plotting an fft function need to plot the folowing:
$$X(j\omega)=\cal F\{{2\over\pi\lambda}\}*\cal F\{sinc(2w_m\lambda)\}-\cal F\{{4\over\pi\lambda}\}*\cal F\{sinc(w_m\lambda)\}$$
as a plot of $|X(j\omega)|$ for $|\omega|<10\pi$
the code I've wrote is:
%% define
t = -4:1/100:4;
w= -10*pi:1/100:10*pi;
wm=3*pi;
z=t-(pi/wm);
a=1./(pi*z);
b=sinc(2*wm*z);
c=sinc(wm*z);
Aa=fft(a);
Bb=fft(b);
Cc=fft(c);
Dd=fft(a);
A1=fftshift(Aa);
B1=fftshift(Aa);
C1=fftshift(Aa);
D1=fftshift(Aa);
x=2*conv(A1,B1)-4*conv(D1,C1);
mag=abs(x);
%%plot
figure;
plot(w,mag,'k','LineWidth',2); 
title('Q1: |X(jw)| - frequency domain');
xlabel('w [hz]','FontSize',12);
ylabel('|X(jw)|','FontSize',12);
legend([{'|X(jw)|'}]);

I know my problem is with the w-axis, but I have no idea on how to fix it.

You have two arrays of different dimensions in your plot.
After running your code, I am told that mag is 1 by 1601 and w is 1 by 6000 something.  

Fix 1 quick and dirty:
w = linspace(-10*pi, 10*pi, 1601);

A better solution is to define w after mag since w isn't used until plotting. Then you can do
Fix 2 (a) and (b):
w = -10*pi:length(mag):10*pi;

or
w = linspace(-10*pi, 10*pi, length(mag));

This way if you change anything in the code that affects the length of mag, then w will change accordingly.


