Simulink Tutorial - 37 - Use C Code Using MATLAB Function Block

preview_player
Показать описание
In this video I have explained how to bring C Code in MATLAB environment using MATLAB function block. It shows the step by step implementation of the method.

Link for s-function using s-function block and basic commands:

Link for how to write function using m-script:
Рекомендации по теме
Комментарии
Автор

Getting this error after run
Unable to determine fixed step size based on sample time in the model, because model does not have any descrete sample times.
But output is getting generated in scope.
Cant generate sfunction file

ashishshinde
Автор

Hey, I need your help. Please reply here If you can help me with similar problem.

aakashdewangan
Автор

Thanx for the vide good job.I have a problem. After the mex file has been created and i want to modify the C code. I re run the simulink model and it doesnt re make the mex. If i try to delete the mex to make a recompilation it says its used by MATLAB. Only workaround is to exit MATLAB delete the mex binary file and then re run the Simulink model.

Anyway here is the code


function y = fcn(u1, u2)
%#codegen
x=0.0;
x=coder.ceval('add_2', u1, u2);

y = x;



#include "addlib.h"

double add_2(double a, double b)
{
return (a + b);
}


header file .h



double add_2(double a, double b);

gamesthatmatter
join shbcf.ru