Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

matlab problem: simple programe

Status
Not open for further replies.

was29e

Junior Member level 2
Joined
Mar 10, 2005
Messages
23
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
amman-jordan
Activity points
1,549
hi, please if anyone can help, i will realy be gratefull, its important to get this code or atleast any part of it, or where to start with it , and without using the DSP tool box.......



write a program to implement the constant_coeffecient linear diffrence equation:

y(n)=Σbi x(n-i) +Σai y(n-i), where for x : (0<=i<=N-1), and for y: (1<=i<=M-1)

for general values of N and M. Assume zero initial conditons, i.e:y(n)=0, for n<0.
1. use the program to determine, and plot the impulse response of the following system:
a-y(n)=x(n)+.9y(n-1)-(.9)^10x(n-10)
is theis system recursive or non recursive, and is it IIR, or FIR?

b.y(n)=.9y(n-1)+x(n)

2. use the prog. to compute and plot y(n) for the examples below:(run the prog. for 30 samples)

a. x(n)=.8^n u(n), and h(n)=1, 0<=n<=4.

b. x(n)=.5^n u(n), and h(n)= (.9^n)u(n),

c. x(n)=cos(2Πn/8 ), and h(n)=1, 0<=n<=7..
 

was29e said:
hi, please if anyone can help, i will realy be gratefull, its important to get this code or atleast any part of it, or where to start with it , and without using the DSP tool box.......



write a program to implement the constant_coeffecient linear diffrence equation:

y(n)=Σbi x(n-i) +Σai y(n-i), where for x :(0<=i<=N-1), and for y:(1<=i<=M-1)

for general values of N and M. Assume zero initial conditons, i.e:y(n)=0, for n<0.
1. use the program to determine, and plot the impulse response of the following system:
a-y(n)=x(n)+.9y(n-1)-(.9)^10x(n-10)
is theis system recursive or non recursive, and is it IIR, or FIR?

b.y(n)=.9y(n-1)+x(n)

2. use the prog. to compute and plot y(n) for the examples below:(run the prog. for 30 samples)

a. x(n)=(.8)^n u(n), and h(n)=1, 0<=n<=4.

b. x(n)=.5^n u(n), and h(n)= (.9^n)u(n),

c. x(n)=cos(2Πn/8), and h(n)=1, 0<=n<=7..
I've requoted your question for easier viewing. This seems like your homework so I won't give you an answer. But the basic way is to express all equations in matrix form.

y(n) = A X + B Y
(1x1) = (1xN)(Nx1) + (1xM)(Mx1)

Togather with the knowledge that y(n) = 0 for n<=0, and b0 = 0, just do a for loop to whatever value of n you want for all values of y(n).

Next, to find impulse response, just let x(n) be an impulse input, ie x(0) = 1, x(n) = 0 for all n!=0.
 

    was29e

    Points: 2
    Helpful Answer Positive Rating
hi, ive been doing thins and trying, but i reached here and i dont know if its right or wrong, and im not sure how to complete, ok any fast comments will help me
thanx


ok heres what ive done , so far,


%inputs
N=input('N= ');
M=input('M= ');
b=input('give me the vector bi starting from the element 0 up to N-1: ');
a=input('give me the vector ai starting from the element 1 up to M-1: ');

%initial conditions
nmax=input('what is the upper bound of n? ');
% you must define x(n) which is the input
% for an impulse response we have:
x=zeros(1,N);
x(1)=1;
y(1)=0; %Subscript indices must be >0 that is y(1) is the initial cond.
for n=1:nmax
sumx(n)=0;
sumy(n)=0;
for i=1:N
if n<=i; %to cancel n<0 elements
else sumx(n)=b(i)*x(n-i)+sumx(n);
end
end
for i=1:M-1
if n<=i; %to cancel n<0 elements
else sumy(n)=a(i)*y(n-i)+sumy(n);
end
end
y(n)=sumx(n)+sumy(n);
end
 

Dear was29e,

It would be nice if you upload your solution in form of M-File of Matlab and put the actual question in the comments at the start of the File....
Then someone will have a look on it,
i prefer to make my own code instead of debugging someone others but in your case it seems to be some type of class assignment and i will recommend you to do by yourself but for your help i am attaching some matlab tutorials and matlab class assignment of Masters course of DSP and i hope you will get lots of useful future assignment too from the collection or some positive help but i will again recommend you to do work by yourself but here is your jump start to be on track just For your Help

Regards
 

dear swahlah....

first i would like to say something about all this, i actualy know nothing about matlab, and i took this DSP couse at this summer term which is an entisive course that have to be taken in 8 weeks, and i have to submit a matlab assig. each tuesday, so the problem is this:
1. im new to DSP
2. im new to matlab
3.i have a communication system course
4.i have no time to learn how to do matlab things, thuogh i realy want to, but in the time being there's no time at all
so i know that i have to do things by my own, but for now im totaly out of ways to do stuff by my own, well i hope now u got the clear idea.
im gratefull for ur comment, and for what u posted, i'll try to work on developing my programming skills as soon as i have time..

thank u...
 

Hi was29e,

just to tell you that at my university here, most are not taught MATLAB and are expected to self learn matlab on top of all other heavy course commitments, and I believe it happens pretty much all place else.

Anyway, back to the topic. You could do it your way, which is the programming way of doing it. It could work, and if your assignment just requires a correct output, then so be it. But MATLAB is a software on matrix, and to harness the power of matrices, you'll have to have everything in the form of matrices, and not treat them as arrays, ie y = A X + B Y. That is matrix multiplication and addition here.

Now, what I would have done, is to create a function that accepts the X and Y verctors as arguments, and spit out the y term. The A and B vectors are your ai/bi coefficients, hence constant vector transpose. Now, you need another function to generate X vector, depending on what the input signal is. You'll also need to feed the appropriate Y vector. You'll probably have to do some manipulation such that time starts from negative time to account for the need of n<=0 information.

So the top level program is a simple for loop, where the computational function is called repeatedly with generated X and Y vectors.

Added after 4 minutes:

Or if you are more ambitious, you can even do away with the for loop.
Instead of y = A X + B Y, you use
Y = A X + B Y instead, and your A and B are actually square matrices, can be large depending on the values of M and N.
After manipulation, Y = (inv(1-B)) A X. You can use matlab functions to find the inverse of (1-B). This method may not be efficient if M or N is too large as the inverse of a large matrix is computationally expensive.
Anyway, the main idea is that, when using MATLAB, think matrices.
 

Dear was29e,
I did not intend to humiliate you but that was just a kind suggestion. No one of us know things from birth so we all learn it by time.
I guessed by your question that you are new to matlab so that's why i posted the tutrials on matlab and if you look at the collection of codes that i have given to you then you will find lots of interesting routines and basic assignment of DSP few on plotting different signals, convolution, and few on polyphase filter too.....

I wish u best luck in your course and must have a look on the files that i uploaded i hope it will help you in your course and in developing your general understanding of DSP and Matlab.....

Just try hard to be on track as early as possible. No matter you are new i think you can do it in a fine way. In addition checkmate has given you the valuable hint for designing so get it.

-Regards
 

HI pepole..
i just want to thank u, for ur help, i think that i will specify sometime to learn matlab, and i will learn to do things by my own, thank u so much, u've been a great help for me
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top