Re: Simulation using Embedded MATLAB Function block in Simulink
- From: "Sarah Bergstrom" <sbergstr@xxxxxxxxxxxxx>
- Date: Mon, 23 Jan 2006 15:36:22 -0500
"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
.
- References:
- Prev by Date: Re: can polyfit give R^2 value for linear fit?
- Next by Date: Re: Maximum relative error in Multidimensional sca
- Previous by thread: Simulation using Embedded MATLAB Function block in Simulink
- Next by thread: redirect console output to gui
- Index(es):
Relevant Pages
|
Loading