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:
matlab function to find average in simulink

Subject: matlab function to find average in simulink

From: Ranmahs

Date: 25 Aug, 2009 07:50:04

Message: 1 of 2

I am using matalb and simulink. Now i want to write a function in simulink. I added a matalb function block in my model. Now i want to take value from input and find the average pf last six values coming as input.
Please help me.. Thanking you in advance.

Subject: matlab function to find average in simulink

From: Phil Goddard

Date: 26 Aug, 2009 02:34:06

Message: 2 of 2

Is the purpose to learn how to incorporate a MATLAB function into Simulink, or to perform the averaging calculation?

If the former then have a look at the doc for the Embedded MATLAB function block (with particular reference to the bits about "persistent" variables), or better still read the How to Write S-Functions documentation.

If the latter, then why not use a Discrete Time Filter (if you have a discrete signal), or build up a very simple system using a series of Memory blocks (if you have a continuous time signal).

There are also several pre-built blocks to do this depending on which Blocksets you have access to.


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