Matlab Summation equation for calculating impulse response of FBMC
9 次查看(过去 30 天)
显示 更早的评论
Hello guys,
I am trying to solve this equation to calculate the impulse response of a filter bank carrier but the graph is not exactly same to what i should get.
Kindly help!
M = 64; %Number of subcarriers
K = 4; %overlapping factor
y=[1 0.97195983 sqrt(2)/2 0.23514695 ]
T= M;
t = linspace (0,100,100)
for k = 1:3
result =(y(1,1)^2* cos(2*pi*k*t/(K*T)) + y(1,2)^2*cos(2*pi*k*t/(K*T))+ y(1,3)^2* cos(2*pi*k*t/(K*T)+ y(1,4)^2* cos(2*pi*k*t/(K*T))));
k
end
result = 1+2*result
plot (result)
采纳的回答
AJAY CHANDRA DORAGARI
2020-8-8
编辑:AJAY CHANDRA DORAGARI
2020-8-8
i understand that you are trying to add harmonics (fundamental upto third ) by computing harmonics at some instants of time and trying to get plot of it
M = 64; %Number of subcarriers
K = 4; %overlapping factor
y=[1 0.97195983 sqrt(2)/2 0.23514695 ]
T= M;
l=K*T; % simplify the equation instead of typing it every time
for k=1:3
for t=0:100
h(k,t+1)=((y(1)^2)*cos((2*k*pi*t)/l))+((y(2)^2)*cos((2*k*pi*t)/l))+((y(3)^2)*cos((2*k*pi*t)/l))+((y(4)^2)*cos((2*k*pi*t)/l))
%here im using t+1 because t=0 cannot be used since indexing must be a positve non zero interger i could use logic(t) but im too lazy
end
end
a=1+(2*sum(h))
plot(a)
xlabel('h(t)')
ylabel('t')
is this the graph you are expecting?
even code can be improved
40 个评论
AJAY CHANDRA DORAGARI
2020-8-8
编辑:AJAY CHANDRA DORAGARI
2020-8-8
i would even like to know whether you are trying to get discrete or a continous one
i assumed that to be continous time function
since you have specified it as a function of 't' rather than 'n'
Sara Nasir
2020-8-9
Hello Ajay,
I am trying to plot the prototype filter in time and frequency domain for which I have to solve the respective formulas. I am just starting of with Matlab coding since it is the part of my project. The graph I should get is something like this.
AJAY CHANDRA DORAGARI
2020-8-9
编辑:AJAY CHANDRA DORAGARI
2020-8-9
I could try if you could attach a file about prototype filter and the mathematical relations about response you want sorry im not an electronics and communications student iam an electrical student but I had a subject signals and systems in my course,so I can try it.I tried searching about prototype filter but couldnt understand the terms associated with the formula.If you could explain the terms I can help you to write the code
Sara Nasir
2020-8-9
okay Ajay I have to plot the frequency response and the impulse response which I am trying to get but the graphs are a little bit different from what is expected.
I have to plot h(t) and H(f) in the chapter 3 of the paper.
Sara Nasir
2020-8-9
Chapter 3 is the topic. This filter known as PHYDYAS filter. I have simulate it in time and frequency domain (in Matlab) using the formulas given for K=overlapping factor=4, M= number of subcarrier = 64 to reproduce figure 6 and Figure 7 . For this I have to use formula of h2(t) and H2(f) in page number 10.
AJAY CHANDRA DORAGARI
2020-8-9
编辑:AJAY CHANDRA DORAGARI
2020-8-9
i have a doubt consider the h(0) instant calculate the value at h(0)
substituting t=0 and k=1,2,3 as per the given formula
h(0)=1+2*(H1*cos(2*pi*0)+H2*cos(4*pi*0)+H3*cos(6*pi*0))
this would be h(0)=1+2(h1+h2+h3)=approx 7
nd in the time response it is given as amplitude =0 at t=0 instant
AJAY CHANDRA DORAGARI
2020-8-9
h(0) calculated manually and h(0) in the graph must match if not the formula or the graph or our interpretation of formula must be wrong
tell me Hk in formula are the values given in the table 1 of page 7 ?
and the value of T is M?
Sara Nasir
2020-8-9
yes the values are from table 1 on page 7.
K=4 and M=64
T is the duration of multicarrier symbol and it is M.
I can also share two forums on which code is given but the formulas are different there.
AJAY CHANDRA DORAGARI
2020-8-9
got it change the formula of time response
it is h(t)=1+summation[((-1)^k)*2*Hk*cos(2*pi*kt/KT)
AJAY CHANDRA DORAGARI
2020-8-9
correct it the formula which they used in the first document which you sent
M = 256; %Number of subcarriers
K = 4; %overlapping factor
y=[1 0.97195983 sqrt(2)/2 0.23514695 ]
T= M;
l=K*T; % simplify the equation instead of typing it every time
t=0:1000;
h=1+2*((-y(1)*cos((2*pi.*t)/l))+(y(2)*cos((4*pi.*t)/l))+(-y(3)*cos((6*pi.*t)/l)));
plot(h)
ylabel('h(t)')
xlabel('t')
grid on
AJAY CHANDRA DORAGARI
2020-8-9
in this code i didnt use the for loop instead used element wise operation
use element wise operation wherever it is possible it is faster than the loop operations
AJAY CHANDRA DORAGARI
2020-8-9
编辑:AJAY CHANDRA DORAGARI
2020-8-9
formula i have seen it first at the ieee paper but i dont know which paper it was then alternatingly added and substracted the terms Hk after trial and error i got it and then cross checked it with the graph and it made sense. Some terms must be substracted to get h(0) value to zero then i remembered generally the terms in fft analysis are alternating with positve and negative signs
Sara Nasir
2020-8-9
M = 64; %Number of subcarriers
K = 4; %overlapping factor
y=[1 0.97195983 sqrt(2)/2 0.23514695 ]
T= M;
l=K*T; % simplify the equation instead of typing it every time
t=0:1000;
h=1+2*((-y(1)*cos((2*pi.*t)/l))+(y(2)*cos((4*pi.*t)/l))+(-y(3)*cos((6*pi.*t)/l)));
plot(h)
ylabel('h(t)')
xlabel('t')
grid on
AJAY CHANDRA DORAGARI
2020-8-9
编辑:AJAY CHANDRA DORAGARI
2020-8-9
no !
for 64 time period take upto t= 200
if you take more than 200 it will repeat again it will appear to be some sine wave where you cant make any distinction
AJAY CHANDRA DORAGARI
2020-8-9
编辑:AJAY CHANDRA DORAGARI
2020-8-9
for 256
you take upto t= 1000 points
just play with it change the values and see the results check for different values of M
AJAY CHANDRA DORAGARI
2020-8-9
im sorry my bad not time period in the previous post
take the value of t=200 for M=64
t=1000 for M=256 (it is small t not capital)
Sara Nasir
2020-8-9
got it! Thankyou
And in the similar way i should calculate the freq response by the formula H(f). No need of for loop?
AJAY CHANDRA DORAGARI
2020-8-9
yes it was the formula which was wrong and ofcourse the code which i used in the first post was wrong too which was a blunder i didnt cross check the formula which you had mentioned .i have taken the expression from your code which you have posted i made a mistake and realised it but in the end i could rectify it
AJAY CHANDRA DORAGARI
2020-8-9
you could getaway maybe this time but even without for loop for frequency analysis the expression might be bit clumpsy because it contains six terms which can be simplified but im no expert i guess you could use it but sometimes you want have any other choice rather than using for loop
AJAY CHANDRA DORAGARI
2020-8-9
i should thanq sara for keeping me busy during this pandemic time i could learn something about phydyas filter and rewind my coding even i started learning matlab just 2 months back for my masters project please do me a favour dont delete this question so i could revisit someday it might help for my own filter problem
Sara Nasir
2020-8-9
I am trying to do with for loop because it is difficult to keep track of six values.
Well I am getting error this time during implementing it.
Sara Nasir
2020-8-9
Can you go through the code please!
There is no error now but nothing on graph.
M = 64; %Number of subcarriers
K = 4; %overlapping factor
H0=1;
H1=0.97195983;
H2=sqrt(2)/2;
H3=0.23514695;
H4=-0.97195983;
H5=-sqrt(2)/2;
H6=-0.23514695;
a=M*K;
f=-1/M:0.001:1/M;
for k=-3:3
for f=-1/M:0.001:1/M
b = f-k/a;
Num = sin(pi*(b)*a);
Den = a* sin(pi*(b));
product=Num./Den;
H = H6*product + H5*product + H4*product + H3*product + H2*product + H1*product + H0*product;
end
end
ab=1+(2*sum(H))
figure(1)
plot (ab)
xlabel('f')
ylabel('H(f)')
AJAY CHANDRA DORAGARI
2020-8-10
i have a doubt
H-1 and H1 are both same the terms used in the frequency response formula
ill try to write my own code first then ill see your code
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 OFDM 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)