First of all, be sure to install c++ compilers 2017 from visual studio, they aren’t automatically selected during the install
If Visual Studio Compilers C++ 2017 aren’t detected you need to add an entry to the registry.
As an admin, edit registry entry:
Add a new “string value” called “15.0” and add a path to the following folder containing visual studio
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\
Start matlab and check that the compiler is found
mex -setup -v