0

I have included the Matlab Function block in a Simulink diagram to call a matlab function.
Now when I want to simulate the Simulink diagram, I get the error:

Errors occurred during parsing of MATLAB function 'MATLAB Function'(#384) 

I however do not find any errors in my matlab function script:

 function out = Sigma(xyz,x1,u)
 x = xyz(1);
 y = xyz(2);
 z = xyz(3);
 out = [-x^3 + 3*x + 2 + 5*y - z + u; ...
        -0.8 - x^2 - 2*x - y;         ...
        0.005*(4*(x1 + 1.77) - z)];
 end

The input xyz is a mux-ed signal with length 3, x1 and u are scalar values. So what is going wrong? Can anyone look through my files (the zip-archive is available here)?

It contains three files.

  • main.m, the main file in some variables are declared and which runs the simulink model
  • Sigma.m, a copy of the matlab function
  • HindmarshRose.mdl, the simulink model.
4

1 回答 1

2

The MATLAB Function block needs to know the size and datatype of the output at initialization. Add the line out = zeros(3,1); before the x = xyz(1); line.

于 2013-06-03T17:08:39.757 回答