Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

m file and differential equation

Status
Not open for further replies.

niteshadw

Electrical
Oct 6, 2006
1
Hi,

I'm new to matlab and I'm trying to figure out how to define and execute differential equations in matlab, for example, how would you define the following equation:

y(n) = x(n) + 2 x(n ? 1) ? 0.95 y(n ? 1)

this is to implement an input signal that is N-samples long, so I guess its (0 [less than or equal to] n [less than or equal to] N [less than or equal to] ?1) but indexing in matlab starts at 1 not 0...this is what I have thus far, can anyone help me out? Thank you

function y = mydiffeq(n)

x(-1) = 0;
y(-1) = 0;


y = mydiffeq(n);
y1 = mydiffeq([0,n]);

 
Replies continue below

Recommended for you

The formating of you post is off on my computer so I am not exactly certain how to answer your question. Try reading this as it might help. If it doesnt maybe post your code so that members of this forum can see what is going on, but be sure to post it with in the "
Code:
unction y = mydiffeq(n)

x(-1) = 0;
y(-1) = 0;


y = mydiffeq(n);
y1 = mydiffeq([0,n]);
" tags and then refer to lines where you have questions. Also tell us what mydiff is.

BsK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor