Re: Simulation using Embedded MATLAB Function block in Simulink



"sabrina" <sihaddadene@xxxxxxxx> wrote in message
news:ef264b7.-1@xxxxxxxxxxxxxxxxxxx
> I don't understand why when I replace sinus by square I have the
> following message:
>
> Coder warning : Function resolved in the MATLAB workspace and will
> only be called during simulation.Function 'Embedded MATLAB Function'
> (#30.317.334), line 13, column 14:"square(2*pi*f0*t)"
>
> Parse error : Simulink Output Data 'signal' (#34) cannot be of MATLAB
> type

This error occurs because SQUARE, unlike SIN, is not part of the Embedded
MATLAB Run-Time library. The full list is shown on our web site, at:

http://www.mathworks.com/access/helpdesk/help/toolbox/simulink/slref/f15-109707.shtml

Thus, SQUARE is handled differently than SIN. Instead of being compiled as
C code, it will be called in MATLAB. This causes the warning that SQUARE
will only work during Simulink simulation, and will not work if you are
using Real-Time Workshop to generate code. The "Parse Error" occurs because
the block is unable to determine the correct size for the output. If you
add the line:
signal=zeros(size(f0));

just before the line which reads:

signal=square(2*pi*f0*t);

you will then be able to run the model. The first line ensures that
Simulink knows what size the output is. For more information on this
behavior, take a look at the section on Functions in Embedded MATLAB Blocks
in the Simulink Documentation. You can view this on our web site, at:

http://www.mathworks.com/access/helpdesk/help/toolbox/simulink/ug/f6-128710.shtml

In particular, the third subsection discusses the same type of situation as
you are experiencing.

Sarah Bergstrom

Mathworks Tech Support


.



Relevant Pages

  • Re: Simulation using Embedded MATLAB Function block in Simulink
    ... Coder warning: Function resolved in the MATLAB workspace and ... will only work during Simulink simulation, and will not work if you ... The "Parse Error" ...
    (comp.soft-sys.matlab)
  • lsqcurvefit in C
    ... I have a problem with the computation time of lsqcurvefit in Matlab. ... I perform a least square minimization over a set of p vectors in ... Hence i wanted to implement Least square ... libraries deal with sets of Vectors but only sets of nx1 points. ...
    (comp.soft-sys.matlab)
  • Re: Damped least square
    ... (Peter Spellucci) ... >>> Does somebody know the matlab function or code for Damped least square ... >M is close to singular when I use least square method. ...
    (sci.math.num-analysis)
  • solving simultaneous equations with specific values
    ... mathstool. ... solving 3 equations for 3 variables but because there is square ... % eventdata reserved - to be defined in a future version of MATLAB ...
    (comp.soft-sys.matlab)
  • Re: MATLAB and SIMULINK real time
    ... di simulink real time direttamente dal linea di comando di ... Matlab non interagisce con simulazioni Simulink, ... Il progetto è un controllo di un robot che deve seguire una ...
    (comp.soft-sys.matlab)

Loading