MATLAB: Does the code generated with Real-Time Workshop execute faster than the same application built in MATLAB

fastfasterfunctionMATLABperformancereal timertwscriptsimulink coderspeedworkshop

I have Simulink model which computes the Eigen Vectors for a matrix and I generated code for the model using Real-Time Workshop. I also wrote an M-script which computes the eigen vectors for the matrix used in the Simulink model. I observe that the M-script is faster than the Real-Time Workshop generated executable.

Best Answer

The reason for the performance difference is that the MATLAB routine EIG uses a highly optimized FORTRAN based library to do the computation which has an advantage over the C based function generated using the MATLAB Embedded Function block. In general, all matrix based computations have a slight advantage in MATLAB when compared to their counterparts developed in C due to the advantages of vectorized matrix reading in FORTRAN and MATLAB compared to the loop based matrix operations in C/C++.