% This is MATLAB CODE with file name Hello.m
%Print out is "Hello World"
function Hello()
fprintf('Hello World\n')
end
==> Now, below is a C- code (Hello.c) in MATLAB to print same words but with the header "mex.h" and mexFunction (link to C main() function)
#include "mex.h"
void mexFunction(int nhls, mxArray *plhs[],
int nrhs, const mxArray *prhs[])
{
mexPrintf("Hello World\n");
}
To run Hello.c in MATLAB, type the below on the console.
mex -setup % Choose the compiler among the list, if not available then install.
mex Hello.c % will run the C program