Implementing Matlab code in a Simulink Matlab function

1 vue (au cours des 30 derniers jours)
MARCO LORENZI
MARCO LORENZI le 6 Avr 2022
Good morning everyone.
Could someone help me implement this code in Simulink?
Functions like makima or smooth does not seem to work in matlab function blocksets.
%% DATA INPUT
dynamic_pressure = 1027.924;
alpha_breakpoints_Fx = [-180 -165 -90 -15 -10 -5 0 5 15 30 60 90 120 150 165 180];
Fx_values = [-450 -395 -11 299 310 290 296 280 315 280 -18 -62 60 -640 -510 -450];
Fx_coefficients = Fx_values/dynamic_pressure;
%% SPACE ALLOCATION
Fx_coefficients_interpolation = zeros(1,360);
alpha_interpolation = zeros(1,360);
%% CUBIC SPLINE INTERPOLATION
for i = 1:361
alpha_interpolation(i) = i-181;
Fx_coefficients_interpolation(i) = makima(alpha_breakpoints_Fx,Fx_coefficients,alpha_interpolation(i));
end
%% Fx
der_Fx_sx = (Fx_coefficients_interpolation(2)-Fx_coefficients_interpolation(1))/(alpha_interpolation(2)-alpha_interpolation(1));
der_Fx_dx = (Fx_coefficients_interpolation(end)-Fx_coefficients_interpolation(end-1))/(alpha_interpolation(end)-alpha_interpolation(end-1));
der_Fx = mean([der_Fx_sx der_Fx_dx]);
Fx_coefficients_interpolation = smooth(alpha_interpolation,Fx_coefficients_interpolation,'sgolay',4);
I am basically trying to fit a set of data using a handmade lookup table using makima as the interpolation method and then smooth the trend of the result to avoid discontinuities.

Réponses (1)

Ganesh Gudipati
Ganesh Gudipati le 13 Avr 2022
Hi,
Once we define the matlab function block, the simulink generates code for that function block. In this case the functions makima and smooth donot support code generation.
Hope this helps.

Catégories

En savoir plus sur Interpolation dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by