4.5. RUNNING MATLAB CODER-GENERATED C CODES ON SMARTPHONES 99
is function calls the function L4_1, where the five output arrays x1 , x2 , y , and y_ac ,
and MSE are returned. To assign y data values to Array, a temporary array called y_temp is
used in a for loop and is filled by y data values:
int i;
double y_temp[length];
for( i = 0; i < length; i++) {
y_temp[i] = y->data[i];
// __android_log_print(ANDROID_LOG_ERROR,
// "HelloWorld Final 1", "%f
", y_temp[i]);
}
Note that for MSE , this step is not needed since it is only one value.
Next, free the allocated memory by copying the following lines from the file main.c:
emxDestroyArray_real32_T(y_ac);
emxDestroyArray_real32_T(y);
emxDestroyArray_real32_T(x2);
emxDestroyArray_real32_T(x1);
Assign y_temp to Array and return it:
(*env)->SetDoubleArrayRegion(env,jArray,0,length,y_temp);
return jArray;
}
ese steps need to be repeated for all the defined outputs in the function L4_1; see the shell
provided for L4_1.
9. Finally, design your desired GUI. is link provides guidelines as how to design GUIs:
http://androidplot.com/docs/quickstart/
4.5.2 RUNNING ON iOS SMARTPHONES
is section covers the steps for integrating a C code generated by the MATLAB Coder into
the Xcode shell previously covered for running it on iPhone smartphones. ese steps are listed
below.
1. Create the shell.
2. Verify the MATLAB function to be run.