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

Thread Subject:
Discrete real-time integration

Subject: Discrete real-time integration

From: Graham

Date: 19 Sep, 2011 16:39:27

Message: 1 of 5

Hi,

Say I have a simple system (1/s) through which I want to pass a signal. I don't have the signal, but only the initial condition x(0).

X(s) --> [1/s] --> Y(s)

Obviously one can easily do this in Simulink. But how do I implement it in Matlab using "normal" code? Sure, I guess I could use something like the Trapezoidal method and do it all manually, but is there not a quicker way to do it?

Many thanks

Subject: Discrete real-time integration

From: Graham

Date: 19 Sep, 2011 17:02:28

Message: 2 of 5

Correction - after initial conditions, I feed in a unit step. I need to perform real-time integration on the incoming signal.

Subject: Discrete real-time integration

From: Anony Mous

Date: 19 Sep, 2011 23:23:09

Message: 3 of 5

On 9/19/2011 12:39 PM, Graham wrote:
> Say I have a simple system (1/s) through which I want to pass a signal.
> I don't have the signal, but only the initial condition x(0).
> X(s) --> [1/s] --> Y(s)
>
> Obviously one can easily do this in Simulink. But how do I implement it
> in Matlab using "normal" code? Sure, I guess I could use something like
> the Trapezoidal method and do it all manually, but is there not a
> quicker way to do it? Many thanks

How do you think Simulink does it?
Why do you think you have a choice of integration methods?
http://en.wikipedia.org/wiki/Numerical_integration
http://demonstrations.wolfram.com/search.html?query=integration

Subject: Discrete real-time integration

From: Graham

Date: 20 Sep, 2011 12:50:15

Message: 4 of 5

Thanks for the reply. Simulink does it "manually" - from the documentation:

"Use initial condition as initial and reset value for parameter:

Step 0: y(0) = x(0) = IC (clipped if necessary)
x(1) = y(0) = x(0) + K*T/2*u(0)

Step 1: y(1) = x(1) + T/2 * (u(1) + u(0))
x(2) = y(1)

Step n: y(n) = x(n) + T/2 * (u(n) + u(n-1))
x(n+1) = y(n)"

But I want to know if there's a shortcut. Please can you direct me to the right "type" of numerical integration - that wolfram link you gave provides wayyyy to many to choose from!

Subject: Discrete real-time integration

From: Zeeshan Shareef

Date: 2 Jan, 2012 17:32:08

Message: 5 of 5

I think you can do it by this code:

At initially
Previous_Value = 0;

New_Value = Previous_Value + Current_Value;
Previous_Value = New_Value;



"Graham " <graham@peyton.co.za> wrote in message <j57r7v$q7i$1@newscl01ah.mathworks.com>...
> Hi,
>
> Say I have a simple system (1/s) through which I want to pass a signal. I don't have the signal, but only the initial condition x(0).
>
> X(s) --> [1/s] --> Y(s)
>
> Obviously one can easily do this in Simulink. But how do I implement it in Matlab using "normal" code? Sure, I guess I could use something like the Trapezoidal method and do it all manually, but is there not a quicker way to do it?
>
> Many thanks

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