There are several functions for taking the inverse of matrix in MATLAB. You can use a MATLAB function block in your model to take the inverse of an input matrix. I attached a picture of a simple model I made to demonstrate this workflow. The MATLAB function block contains the following code:
function y = fcn(u)
y = inv(u);
I have included links to documentation for the MATLAB function block and a couple of useful inverse functions below:
https://www.mathworks.com/help/simulink/ug/creating-an-example-model-that-uses-a-matlab-function-block.html https://www.mathworks.com/help/matlab/ref/inv.html https://www.mathworks.com/help/matlab/ref/pinv.html
In regards to creating a C S-function in Simulink, the process for manually creating an S-function can be rather particular. I have included documentation below for tools we have to make this process easier if you are still interested in using C S-functions: