Simulink cannot determine sizes and/or types of the outputs for block 'MATLAB Function'
101 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a small Simulink model as follows:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/195594/image.jpeg)
and the resepctive code:
function [xdot,y] = fcn(x,u)
% define your constants
g = 9.81;
m = 0.05;
R = 1;
L = 0.01;
C = 0.0001;
x1 = 0.012;
x2 = 0;
x3 = 0.84;
% nonlinear set of equations
xdot = [x2; g-((C/m)*(x3/x1)^2); -((R/L) +(((2*C)/L)*(((x2*x3)/((x1)^2)))))] + [0;0;1/L]*u;
y = x';
However when I try to run, Simulink generates the following errors:
Inferred size ('[1 3]') for data 'y' does not match specified size ('scalar').
Component:MATLAB Function | Category:Coder error
Simulink cannot determine sizes and/or types of the outputs for block '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.
I searched through some documentation for variable size inputs and outputs, selected the variable size check box and also entered the upper bound as [1 3].
When I try to run again I get:
Expression '[1 3]' for maximum of data 'y' must evaluate to a scalar.
Any help would be appreciated.
0 comentarios
Respuestas (1)
泊先 姚
el 14 de Sept. de 2021
You can set all of those options back to their default values.
0 comentarios
Ver también
Categorías
Más información sobre Event Functions en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!