Effacer les filtres
Effacer les filtres

Simulink cannot determine sizes and/or types of the outputs for block 'MATLAB Function'

101 vues (au cours des 30 derniers jours)
I have a small Simulink model as follows:
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.
I'm not sure how to solve this error. I also looked here, but still couldnt get it to work.
Any help would be appreciated.

Réponses (1)

泊先 姚
泊先 姚 le 14 Sep 2021
You can set all of those options back to their default values.

Catégories

En savoir plus sur Event Functions dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by