Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

Thread Subject:
S Functions or Matlab function blocks

Subject: S Functions or Matlab function blocks

From: Aravind VJ

Date: 15 Jul, 2012 11:34:27

Message: 1 of 2


I am an electronics engineer. Interested in using simulink. I am trying to do FFT inside an S function block (I am new to simulink, but have some experience with matlab). Somone please guide me on this


Subject: S Functions or Matlab function blocks

From: Phil Goddard

Date: 15 Jul, 2012 14:00:07

Message: 2 of 2

There is an FFT block in the Signal Processing Blockset is you have access to it.

Otherwise you could use either a MATLAB Fcn block or an S-Function.

Assuming the input signal is sample based (i.e. scalar at each time step), then the first thing you need to do is buffer the signal into an appropriate length vector before performing the fft.
Within an S-function you'd do that with a DWork vector.
Within a MATLAB Fcn block you'd need to use a persistent variable.

If you intend using the MATLAB fft function then within a MATLAB Fcn block you'll need to define fft as being coder.extrinsic.


Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us