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.

Problem with plotting the magnitude and phase response of a signal in Matlab

Status
Not open for further replies.

scdoro

Member level 5
Joined
Jan 12, 2005
Messages
87
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,040
Hi all,

Below section of code asks to plot the magnitude and the phase response graph of the signal xn.


a = 0.88 * exp( j*2*pi/5 );
nn = 0:40;
xn = a.^nn;
for n = 128.

Qn1) when i typed in this section of code and try to run it using Matlab, it just keeps looping and there is no output. How can i make use of the above information to obtain the magnitude and phase response of the signal?
The full question is provided in the attachment


Thanks

P.S: i am new to matlab so i hope someone could helped me with this

regards
scdoro
 

hr_rezaee

Advanced Member level 3
Joined
Oct 6, 2004
Messages
751
Helped
109
Reputation
218
Reaction score
24
Trophy points
1,298
Location
Iran-Mashhad
Activity points
4,025
new to matlab

hi
a = 0.88 * exp( j*2*pi/5 );
nn = 0:40;
xn = a.^nn;
for n = 128

becuse your loop is incomplete.

for n=1:128
...
end

see function abs() and angle() in matlab help.
 

Roshdy

Member level 3
Joined
Nov 23, 2005
Messages
58
Helped
2
Reputation
4
Reaction score
0
Trophy points
1,286
Location
Egypt
Activity points
1,750
Re: new to matlab

Also no output function used, you said that you want to "plot the magnitude and the phase" you have to use a plot function (eg. plot, semilogx,.....).
 

Element_115

Advanced Member level 2
Joined
Mar 23, 2002
Messages
509
Helped
72
Reputation
144
Reaction score
43
Trophy points
1,308
Activity points
3,759
Re: new to matlab

That question is bad!

There is no "n" variable.


a = 0.88 * exp( j*2*pi/5 ); % This is a Complex number
nn = 0:40; % This is an array [1,2,3...39,40]
xn = a.^nn; % "xn" is a Complx # raised to a power "nn"
for n = 128. % this looks like it wants to be a loop w/128 iterations
% but nothing is done. Or a statement and "n" should be "nn", but "nn" MAX = 40!

Type plot(nn,xn) or plot(xn), and see if this helps you understand your original
question.
 

MSGHP

Junior Member level 1
Joined
Jan 16, 2006
Messages
15
Helped
2
Reputation
4
Reaction score
0
Trophy points
1,281
Location
Iran
Activity points
1,409
new to matlab

% your signal is alittle strange because it's complex and so your frequency response don't have symetri in magnitude an asymetry in phase

a=0.88*exp(i*2*pi/5); % matlab use i instead of j
nn=0:40;
xn=a.^n;
n=128;
Xw=fftshift(fft(xn,n)); % u have to compute the frequency reponse by n sample
plot(0:n-1,abs(Xw)); % plots the magnitude of frequency responce
figure;
plot(0:n-1,angle(Xw)); % plots the phase


% for more information refer to matlab help for fft
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top