Using AFNI commands in Matlab

AFNI experts,

I know there is a package for Matlab interface.
However, what I want to do is to use “system” command in Matlab to directly use AFNI commands.
Currently, I thought I changed the default SHELL from bash to tshell.
However, Matlab did not recognize it.
I also checked to change Matlab environment setting in the link,
https://kr.mathworks.com/help/matlab/matlab_external/changing-environment-variables-for-shell-escape-functions.html#responsive_offcanvas

It also did not work.
When I type system(‘tcsh’) in Matlab command line.
Matlab command line changed into terminal, and I never come back to matlab command line again.

Would you help me out with this issue?

Sincerely,
Sungshin Kim

Mostly, running shell commands in Matlab works fine, and little has to be specific for AFNI programs to work. Matlab uses the sh shell (neither bash nor tcsh, but the Bourne shell), and the configuration for that shell needs to be correct. You can either have Matlab use a different shell through environment variables like MATLAB_SHELL or add PATH and DYLD_LIBRARY_PATH to a .profile file in your home directory. On a Mac, you may also need to set DYLD_LIBRARY_PATH in the terminal or shell used to start MATLAB and launch from the command line rather than run it from a GUI launcher. Security protection implemented on the MacOS could be turned off too. See these links for some more info.

https://www.mathworks.com/matlabcentral/answers/312837-change-shell-used-by-matlab
http://osr600doc.xinuos.com/en/SHL_custom/_The_Bourne_shell_profile.html
https://www.mathworks.com/matlabcentral/answers/374930-append-library-path-to-dyld_library_path-in-mac
https://afni.nimh.nih.gov/afni/community/board/read.php?1,149775,149775