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

New to MATLAB?

# Thread Subject: Dirac Delta Question

Subject: Dirac Delta Question

From: Sam

### Sam (view profile)

Date: 17 Jan, 2013 21:42:09

Message: 1 of 13

Hey y'all, I'm very confused as to how to numerically incorporate dirac delta behaviour into my differential equation. Maybe I'm using a wrong approach? I keep getting error messages to no avail. Any advice would be greatly appreciated!

function dirac
close all
clc; clear

%Parameters:
G=1.07;
w=2*pi;
w0=(1.5)*w;
B=(w0)/4;

% Initial Conditions
y0 = [0,0];

% Make a theta vs. time plot
[t,y] = ode23(@f,[0 25],y0,[],G,w,w0,B);

hold all
plot(t,y(:,1))

function dydt = f(t,y,G,w,w0,B)
dydt = [y(2);-2*B*y(2)-(w0^2)*sin(y(1))+G*(w0^2)*cos(w*t)+dirac(t-5)];

Subject: Dirac Delta Question

From: Bruno Luong

### Bruno Luong (view profile)

Date: 17 Jan, 2013 22:45:09

Message: 2 of 13

"Sam " <samnuzbrokh@yahoo.com> wrote in message <kd9r7h$38b$1@newscl01ah.mathworks.com>...
> Hey y'all, I'm very confused as to how to numerically incorporate dirac delta behaviour into my differential equation. Maybe I'm using a wrong approach? I keep getting error messages to no avail. Any advice would be greatly appreciated!
>
> function dirac
> close all
> clc; clear
>
> %Parameters:
> G=1.07;
> w=2*pi;
> w0=(1.5)*w;
> B=(w0)/4;
>
> % Initial Conditions
> y0 = [0,0];
>
> % Make a theta vs. time plot
> [t,y] = ode23(@f,[0 25],y0,[],G,w,w0,B);
>
> hold all
> plot(t,y(:,1))
>
> function dydt = f(t,y,G,w,w0,B)
> dydt = [y(2);-2*B*y(2)-(w0^2)*sin(y(1))+G*(w0^2)*cos(w*t)+dirac(t-5)];

- Solve ode on the interval t in [0,5),
- take y5 = y(t=5)+[0;1] as initial condition to solve ode on the interval t = (5,25]

Bruno

Subject: Dirac Delta Question

From: Roger Stafford

### Roger Stafford (view profile)

Date: 17 Jan, 2013 23:34:08

Message: 3 of 13

"Sam " <samnuzbrokh@yahoo.com> wrote in message <kd9r7h$38b$1@newscl01ah.mathworks.com>...
> Hey y'all, I'm very confused as to how to numerically incorporate dirac delta behaviour into my differential equation. Maybe I'm using a wrong approach? I keep getting error messages to no avail. Any advice would be greatly appreciated!
>
> function dirac
> close all
> clc; clear
>
> %Parameters:
> G=1.07;
> w=2*pi;
> w0=(1.5)*w;
> B=(w0)/4;
>
> % Initial Conditions
> y0 = [0,0];
>
> % Make a theta vs. time plot
> [t,y] = ode23(@f,[0 25],y0,[],G,w,w0,B);
>
> hold all
> plot(t,y(:,1))
>
> function dydt = f(t,y,G,w,w0,B)
> dydt = [y(2);-2*B*y(2)-(w0^2)*sin(y(1))+G*(w0^2)*cos(w*t)+dirac(t-5)];
- - - - - - - - - - -
You cannot actually do numerical computation using the dirac delta function directly. It is only numerically meaningful in its integrated form as a unit step function. That is, its integral from 0 to 0 is understood to be 1. That of course is impossible for ordinary numerical integration to accomplish. For that reason you have to treat it in special ways such as with the method Bruno has suggested. Some of the symbolic tools are also able to handle it properly but never, never try to compute numerically with it directly.

Roger Stafford

Subject: Dirac Delta Question

From: Carl S.

### S C.Carl (view profile)

(Carl S.)

Date: 6 Feb, 2013 13:44:08

Message: 4 of 13

Hi

I have a question about Dirac delta (not as in a matlab function, my question is related to its theory)

Assume that you have a vector v. If the value of v is equal to zero then the result of the dirac delta of v is zero (so, it does not matter it is a vector or scalar) If the value of v is not zero then what is the result of the dirac delta function of the vector v? Is the result a vector or scalar value ?

"Roger Stafford" wrote in message <kda1pg$p98$1@newscl01ah.mathworks.com>...
> "Sam " <samnuzbrokh@yahoo.com> wrote in message <kd9r7h$38b$1@newscl01ah.mathworks.com>...
> > Hey y'all, I'm very confused as to how to numerically incorporate dirac delta behaviour into my differential equation. Maybe I'm using a wrong approach? I keep getting error messages to no avail. Any advice would be greatly appreciated!
> >
> > function dirac
> > close all
> > clc; clear
> >
> > %Parameters:
> > G=1.07;
> > w=2*pi;
> > w0=(1.5)*w;
> > B=(w0)/4;
> >
> > % Initial Conditions
> > y0 = [0,0];
> >
> > % Make a theta vs. time plot
> > [t,y] = ode23(@f,[0 25],y0,[],G,w,w0,B);
> >
> > hold all
> > plot(t,y(:,1))
> >
> > function dydt = f(t,y,G,w,w0,B)
> > dydt = [y(2);-2*B*y(2)-(w0^2)*sin(y(1))+G*(w0^2)*cos(w*t)+dirac(t-5)];
> - - - - - - - - - - -
> You cannot actually do numerical computation using the dirac delta function directly. It is only numerically meaningful in its integrated form as a unit step function. That is, its integral from 0 to 0 is understood to be 1. That of course is impossible for ordinary numerical integration to accomplish. For that reason you have to treat it in special ways such as with the method Bruno has suggested. Some of the symbolic tools are also able to handle it properly but never, never try to compute numerically with it directly.
>
> Roger Stafford

Subject: Dirac Delta Question

From: Bruno Luong

### Bruno Luong (view profile)

Date: 6 Feb, 2013 14:00:10

Message: 5 of 13

"Carl S." wrote in message <ketmn8$gs9$1@newscl01ah.mathworks.com>...
> ... the dirac delta of v ...

The expression above alone does not make meaningful sense. A dirac is a function (to be more precise a distribution). There is no such thing as "the dirac of somethingelse".

Bruno

Subject: Dirac Delta Question

From: Carl S.

### S C.Carl (view profile)

(Carl S.)

Date: 6 Feb, 2013 14:15:09

Message: 6 of 13

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <ketnla$ki1$1@newscl01ah.mathworks.com>...
> "Carl S." wrote in message <ketmn8$gs9$1@newscl01ah.mathworks.com>...
> > ... the dirac delta of v ...
>
> The expression above alone does not make meaningful sense. A dirac is a function (to be more precise a distribution). There is no such thing as "the dirac of somethingelse".
>
> Bruno

Sorry Bruno, I mean that the result of the dirac delta function of the parameter v.
Here, v is a vector. What is the result of the function? A vector ? A scalar ?

Subject: Dirac Delta Question

From: Bruno Luong

### Bruno Luong (view profile)

Date: 6 Feb, 2013 14:42:09

Message: 7 of 13

"Carl S." wrote in message <ketohd$o93$1@newscl01ah.mathworks.com>...
> "Bruno Luong" <b.luong@fogale.findmycountry> wrote in message
>
> Sorry Bruno, I mean that the result of the dirac delta function of the parameter v.
> Here, v is a vector. What is the result of the function? A vector ? A scalar ?

The result is meaningless, since you ask something that does not make any sense to me. There is no such thing as "dirac of a vector".

I just repeat what I said earlier.

Bruno

Subject: Dirac Delta Question

From: Carl S.

### S C.Carl (view profile)

(Carl S.)

Date: 6 Feb, 2013 14:51:08

Message: 8 of 13

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <ketq40$1pr$1@newscl01ah.mathworks.com>...
> "Carl S." wrote in message <ketohd$o93$1@newscl01ah.mathworks.com>...
> > "Bruno Luong" <b.luong@fogale.findmycountry> wrote in message
> >
> > Sorry Bruno, I mean that the result of the dirac delta function of the parameter v.
> > Here, v is a vector. What is the result of the function? A vector ? A scalar ?
>
> The result is meaningless, since you ask something that does not make any sense to me. There is no such thing as "dirac of a vector".
>
> I just repeat what I said earlier.
>
> Bruno

If v is a vector valued function, then ?

for example: C = [x(teta) y(teta)] and v(C, t). In this case, is the result of the dirac delta function of v meaningful ? If yes, what is its value ? a vector ?

Subject: Dirac Delta Question

From: Nasser M. Abbasi

### Nasser M. Abbasi (view profile)

Date: 6 Feb, 2013 14:57:45

Message: 9 of 13

On 2/6/2013 8:51 AM, Carl S. wrote:

>
> If v is a vector valued function, then ?
>
> for example: C = [x(teta) y(teta)] and v(C, t). In this case, is the result
>of the dirac delta function of v meaningful ? If yes, what is its value ? a vector ?
>

What is your defintion of "dirac delta function" ?

You really can't just use or apply something if you do not know what it is
you are using.

May be you should read this first:

http://en.wikipedia.org/wiki/Dirac_delta_function

--Nasser

Subject: Dirac Delta Question

From: Bruno Luong

### Bruno Luong (view profile)

Date: 6 Feb, 2013 15:59:08

Message: 10 of 13

"Carl S." wrote in message <ketqks$3vt$1@newscl01ah.mathworks.com>...

>
> for example: C = [x(teta) y(teta)] and v(C, t). In this case, is the result of the dirac delta function of v meaningful ? If yes, what is its value ? a vector ?

A Dirac "function" (x is variable) is a distribution. The standard mathematic notation is "delta(x)", and it has zero value every where excepted at x=0 (its "support"), and integral of dirac is 1.

When one notes f=delta(x - 4), it is a composition of a dirac function with the function (x -> y:=x-4). Meanig that that f is the standard delta that is shifted so that the support is at x=4 (since when x=4, y = x-4=0) .

Many be you want to know g = delta(v(C,t)) (dirac of V), that mean a 2D "function" that has support at the set of points S = { v(C,t) = 0 } (+ some integral property). g is a distribution (function if you like), but is certainly not scalar or vector.

Bruno

Subject: Dirac Delta Question

From: M Antola

### M Antola (view profile)

Date: 28 Feb, 2013 17:52:08

Message: 11 of 13

"Carl S." wrote in message <ketohd$o93$1@newscl01ah.mathworks.com>...
> "Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <ketnla$ki1$1@newscl01ah.mathworks.com>...
> > "Carl S." wrote in message <ketmn8$gs9$1@newscl01ah.mathworks.com>...
> > > ... the dirac delta of v ...
> >
> > The expression above alone does not make meaningful sense. A dirac is a function (to be more precise a distribution). There is no such thing as "the dirac of somethingelse".
> >
> > Bruno
>
> Sorry Bruno, I mean that the result of the dirac delta function of the parameter v.
> Here, v is a vector. What is the result of the function? A vector ? A scalar ?

In theoretical physics at least, one means with \delta(x), where x is a vector, the product \delta(x_1)\delta(x_2)\delta(x_3) .. and so on. So the result is a scalar.

Subject: Dirac Delta Question

From: Bruno Luong

### Bruno Luong (view profile)

Date: 28 Feb, 2013 18:37:08

Message: 12 of 13

"M Antola" <matti.antola@helsinki.fi> wrote in message <kgo5g8$amh$1@newscl01ah.mathworks.com>...

> In theoretical physics at least, one means with \delta(x), where x is a vector, the product \delta(x_1)\delta(x_2)\delta(x_3) .. and so on.

OK

>So the result is a scalar.

This statement does not make sense. A distribution is NOT a scalar.

Bruno

Subject: Dirac Delta Question

From: Greg Heath

### Greg Heath (view profile)

Date: 1 Mar, 2013 06:43:05

Message: 13 of 13

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <kgo84k$jt5$1@newscl01ah.mathworks.com>...
> "M Antola" <matti.antola@helsinki.fi> wrote in message <kgo5g8$amh$1@newscl01ah.mathworks.com>...
>
> > In theoretical physics at least, one means with \delta(x), where x is a vector, the product \delta(x_1)\delta(x_2)\delta(x_3) .. and so on.
>
> OK
>
> >So the result is a scalar.
>
> This statement does not make sense. A distribution is NOT a scalar.
>
> Bruno

I think the biggest mistake is to even mention the words "function" and "value" when dealing with someone who does not understand the basic concept of distribution theory.

Greg