Hi long le,
Matlab documentation is quite nice since it provides several examples on key topics. One possibility to transform time dependent signal into frequency domain is the fast fourier transform (short: fft). Matlab has an inbuilt function for that. How to use it is described in the documentation: https://de.mathworks.com/help/matlab/ref/fft.html
Whether the Shannon-limit is respected or not, you can question using an if-statement before the domain transformation (https://de.mathworks.com/help/matlab/ref/if.html)
Kind regards,
Robert