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.
Edit Registry
Matlab Source
Edit Registry
As an admin, edit registry entry:
HKLM\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\SxS\VS7
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