Program for Impulsive Difference Equations

Write a MATLAB program to simulate the following impulsive difference equation
where , , , and , for
(a) Find values of y[n] (b) plot the solutions over the range, 1= n = 10.

2 Kommentare

Jon
Jon am 19 Aug. 2019
What have you tried to do so far? What problems have you encountered? Please include your code using the code button on the MATLAB answers toolbar.
Gokula Nanda
Gokula Nanda am 20 Aug. 2019
I am acquainted with the solution of difference equations. But no idea, how can i program the equations with impulse?

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Jon
Jon am 20 Aug. 2019

1 Stimme

One way to approach this is to transform your difference equation in the single variable y to a system of two difference equations, which you can simply march forward in time.
So neglecting, for the moment the special condition when n = mk, you could define y1(n) = y(n) and y2(n) = y1(n-1), noting also that a(n), b(n) and c(n) are in fact not functions of n, but simple constants, and substituting for h(u) would give the system of equations
y1(n+1) = a*y1(n) - b*y2(n) - c*y2(n)^3
y2(n+1) = y1(n)
Assuming you have initial conditions for y you could then just march forward in a loop
a = -3/2
b = 1
c = 1/4
% assign initial conditions
y1(1)= y1ic % initial condition y for n=1
y2(1)= y2ic % initial condition y for n=0
% assign maximum iteration
nFinal = 11
% loop to march forward
preallocate
y1 = zeros(nFinal+1,1)
y2 = zeros(nFinal+1,1)
for n = 1:nFinal
y1(n+1) = a*y1(n) - b*y2(n) - c*y2(n)^3
y2(n+1) = y1(n)
end
% plot results (note y1 = y the variable you are interested in)
plot(y1) % with only one argument the x axis will just be the value of n
You will have to further modify your code to handle the special condition where n = m*k. I actually can't understand the details of what your are doing there from the description, for example I don't see where I_k is defined.
Hopefully this gives you a start on how to approach this.

4 Kommentare

Gokula Nanda
Gokula Nanda am 21 Aug. 2019
Here, I_k is any positive real contsant. After execution, there is a error message in the programming "undefined preallocated" and another error in "initial condition".
Jon
Jon am 21 Aug. 2019
Bearbeitet: Jon am 21 Aug. 2019
I was just trying to give you an outline of an approach. The error "undefined preallocated" is due to an error I made typing in the example. There should be a comment % in front of the word preallocate, so change
% loop to march forward
preallocate
y1 = zeros(nFinal+1,1)
to
% loop to march forward
% preallocate
y1 = zeros(nFinal+1,1)
I don't know exactly what error you had regarding initial conditions, but likely it was that y1ic and y2ic are undefined. I didn't know what numerical values you wanted to assign as initial conditions, I was just putting those in as a place holder to show that you would need to assign initial conditions
You would need to add some lines something like (I just made up some numbers here to illustrate, you will have to assign values that make sense for your problem, maybe zero
a = -3/2
b = 1
c = 1/4
y1ic = 5.3
y2ic = 13.8
% assign initial conditions
y1(1)= y1ic % initial condition y for n=1
y2(1)= y2ic % initial condition y for n=0
As I said earlier, you will have to further modify this code to include treating your I_k. Hopefully you can see your way through doing that now that you have a start.
Gokula Nanda
Gokula Nanda am 21 Aug. 2019
Thank you very much.
Jon
Jon am 21 Aug. 2019
Your welcome. Glad to hear this worked. Good luck with your project

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Communications Toolbox finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 19 Aug. 2019

Kommentiert:

Jon
am 21 Aug. 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by