How to construct ideal low pass filter in matlab? Firstly, I was asked to construct a signal $x(t)= 2 \cos(2 \pi f_1 t) + 1.5 \sin(2 \pi f_2 t) $ with $f_1= 100, f_2=200, t= 50 \textrm{ms}, Fs= 1\textrm{kHz}$ and number of FFT points $N = 1024$ and my code until this part is below.

f1=100;
f2=200;
fs= 1000;
N= 1024;
t=0:1/fs: 0.05;

x= 2*cos(2*pi*f1*t) + 1.5*sin(2*pi*f2*t)


I don't know that if this is the ideal low pass filter with frequency $f_c$, how to construct it in MATLAB?
The ideal lowpass filter is an infinitely long sinc function. It's Fourier transform is a rectangular shape as shown in your frequency spectrum diagram. In practice you have to window (truncate) it to a certain number of samples. The periodic width of the lobes of the sinc will correspond to the width of your frequency rectangle (lowpass cutoff frequency)