MATLAB: Dimensions of matlab function block

matlab functionoutput dimension

Hello,
I have the following code
function [Fx1, Fy1, Fx2, Fy2, Fx3, Fy3, Fx4, Fy4]= fcn(u)
%Parameter laden
Moseberg;
F_max = (1:4);
%Input definition
% target trajectory
Fx_V = u(1);
Fy_V = u(2);
Mz_V = u(3);
%calculated friction border
F_max(1) = u(4);
F_max(2) = u(5);
F_max(3) = u(6);
F_max(4) = u(7);
y = @m;
but I keep getting these errors.
This text contains non-empty top-level expressions. It appears to be a script.
Function 'Moseberg.m' (#51.0.0), line 0, column 0:
""
Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Errors occurred during parsing of MATLAB function 'FTR_diskret/CarMaker/VehicleControl/FTR1/Fahren/Aufteilung der Überaktuierung /Kräfteaufteilung/kritischer Fahrbereich/MATLAB Function'
Component:MATLAB Function | Category:Coder error
Simulink cannot determine sizes and/or types of the outputs for block 'FTR_diskret/CarMaker/VehicleControl/FTR1/Fahren/Aufteilung der Überaktuierung /Kräfteaufteilung/kritischer Fahrbereich/MATLAB Function' due to errors in the block body, or limitations of the underlying analysis. The errors might be inaccurate. Fix the indicated errors, or explicitly specify sizes and/or types for all block outputs.
Component:MATLAB Function | Category:Coder error
Compilation of model 'FTR_diskret' failed while trying to resolve underspecified signal dimensions.
Suggested Actions
Enable 'warning' or 'error' diagnostics for the list of underspecified signal dimensions.
Open
Caused by:
Simulink cannot determine sizes and/or types of the outputs for block 'FTR_diskret/CarMaker/VehicleControl/FTR1/Fahren/Aufteilung der Überaktuierung /Kräfteaufteilung/kritischer Fahrbereich/MATLAB Function' due to errors in the block body, or limitations of the underlying analysis. The errors might be inaccurate. Fix the indicated errors, or explicitly specify sizes and/or types for all block outputs.
Error occurred in 'FTR_diskret/CarMaker/VehicleControl/FTR1/Fahren/Aufteilung der Überaktuierung /Kräfteaufteilung/kritischer Fahrbereich/MATLAB Function'.
Can someone help me how to fix the dimensions?

Best Answer

It looks to me as if MATLAB Function Block cannot invoke scripts .
Your Moseberg appears to be a script.
coder.extrinsic('Mosebergfct')
Mosebergfct;
coder.extrinsic('ParameterSarah')
ParameterSarah;
You are using Mosebergfct and ParameterSarah as if they are scripts as well. You should convert them into functions (returning appropriate variables) that are called each time, or else convert them into functions that you call once at the beginning and pass the values around.
Simulink Code Generator demands a lot of transparency.