Here, Basic simulink models using matlab function as well as C programming based S-function are attached. This will help to generate and verify C-equivalent of the matlab code in simulink itself. Mex command is used for C program compilation. Run m-file and verify that matlab and c-function output matches.