MATLAB: Variable size of simulink matlab function

simulink

function desired = path_planning(data_points,slope0,slopeF,dt)
t_dummy=0:((length(data_points))-1);
tq=0:(dt/10):((length(data_points))-1);
desired=spline(t_dummy,[slope0; data_points; slopeF],tq);
end
error "Data 'desired' is inferred as a variable size matrix, while its properties in the Model Explorer specify its size as inherited or fixed. Please check the 'Variable Size' check box and specify the upper bounds in the size field."
i am also attaching the simulink file, can you please see what is issue here? the same function works fine in matlab but not in simulink.

Best Answer

Run the attached model. What you basically needed to do is to go to Model Explorer and set the output of the MATLAB Function as variable size by checking the tickbox there. Also, specify the size of the output.