It is unlikely that Matlab is the issue. Please follow the steps below to verify that your OpenFOAM installation is working correctly:
1) Uninstall all OpenFOAM versions and Microsoft MPI if present and reboot
2) Download and install ESI-OpenFOAM (
https://sourceforge.net/projects/openfoam/files/v2206/OpenFOAM-v2206-windows-mingw.exe)
3) Download and install Microsoft MPI (
https://learn.microsoft.com/en-us/message-passing-interface/microsoft-mpi)
4) Download and extract the linked test case
channel_flow.zip to a folder, for eaxmple "C:\temp\channel_flow".
5) Open a Windows CMD shell (Win+R > cmd > Enter) and run the following code (substitute v2206 for your ESI-OpenFOAM version), possibly try temporarily disabling any Anti Virus programs during the testing:
> %USERPROFILE%\AppData\Roaming\ESI-OpenCFD\OpenFOAM\v2206\setEnvVariables-v2206.bat
> %USERPROFILE%\AppData\Roaming\ESI-OpenCFD\OpenFOAM\v2206\msys64\home\ofuser\OpenFOAM\OpenFOAM-v2206\platforms\win64MingwDPInt32Opt\bin\simpleFoam.exe -help
> %USERPROFILE%\AppData\Roaming\ESI-OpenCFD\OpenFOAM\v2206\msys64\home\ofuser\OpenFOAM\OpenFOAM-v2206\platforms\win64MingwDPInt32Opt\bin\simpleFoam.exe -case C:\temp\channel_flow
6) The solver should run without error. If it doesn't please go back and follow the ESI OpenFOAM quickstart guide (
https://doc.openfoam.com/2306/quickstart)