MATLAB: MATLAB environment variables issue with MacTeX 2020

environment variablepath

Hello
I'm running several matlab script include using xelatex to compile LaTex code and export to pdf. I downloaded c from the official website and installed successfully, but I keep having this error when I run my script. I use Mac system in MacOS High Sierra and the code was run locally using matlab2020
/bin/bash: xelatex: command not found
...
LaTeX compilation failed.
I searched for lots of answers, the one I found the most useful is this one: https://www.mathworks.com/matlabcentral/answers/850-matlab-environment-variables
I used the suggestion from the answer to set :
setenv([getenv('PATH') ':/usr/texbin']);
setenv([getenv('PATH') ':/usr/local/bin']);
also
setenv('PATH', [getenv('PATH') '::/usr/local/bin']);
then I thought the installation path for MacTeX 2020 might changed, I found this: "The default installation directory is /usr/local/texlive/2020 on Unix"
after change the path and run this
setenv('PATH', [getenv('PATH') ':/usr/local/texlive/2020/']);
Still does not work and the same error showed up
Does anyone know how to fix this? Thanks!

Best Answer

(summarizing)
The one from http://www.texts.io/support/0001/ installs into /Library/TeX/texbin/xelatex
setenv('PATH', [getenv('PATH') '/Library/TeX/texbin']);