Need help with my matlab code Basically I need a loop that performs the manual c
ID: 2085262 • Letter: N
Question
Need help with my matlab code
Basically I need a loop that performs the manual code I wrote below. I put a for loop to try to get the results from the manual code for a given n value but it's not giving me the same results. Can someone help me fix this loop ?
Thank you !
clc
clear all
%p represents poles of the filter
p0=exp(1*i*pi/4);
p1=exp(1*i*3*pi/4);
p2=exp(1*i*5*pi/4);
p3=exp(1*i*7*pi/4);
%real function gets the real poles
real(p0);
real(p1);
real(p2);
real(p3);
% need to make a loop for the code above
n=2;
for k=0:(2*n-1)
p=exp(1*i*pi+2*k*pi/2*n)
real(p);
end
%not getting the same results on the for loop as the one above
Explanation / Answer
code:
clc;
clear all;
close all;
n=2;
for k=0:(2^n)-1
p=exp((2*k+1)*i*pi/2^n)
y=real(p)
end
result:
p =
0.7071 + 0.7071i
y =
0.7071
p =
-0.7071 + 0.7071i
y =
-0.7071
p =
-0.7071 - 0.7071i
y =
-0.7071
p =
0.7071 - 0.7071i
y =
0.7071
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.