フィルターのクリア

plot a signal in the freq domain

3 ビュー (過去 30 日間)
Nicolas
Nicolas 2012 年 3 月 7 日
Hello!! I am trying to plot this function X= m*((sin(pi*f/2*m)*sin(pi*f/n))/pi*f*cos(pi*f/2*m))^2;
that is in the freq domain, but when I get the plot is empty. This function is the theorically spectrum of a BOC modulation, so I guess that I can not do fft or pwelch or stuff like that, so I dont know how to plot it in the f domain. I thought is gonna be samething easy as
for f=1:100:100000;
X= m*((sin(pi*f/2*m)*sin(pi*f/n))/pi*f*cos(pi*f/2*m))^2;
end
plot(f,X)
but is not working I will appreciate a lot is someone can give me a hint Thanks in advance Nicolas
  2 件のコメント
Honglei Chen
Honglei Chen 2012 年 3 月 7 日
When you say plot is empty, did you check what's in X?
Thomas
Thomas 2012 年 3 月 7 日
what are 'm' and 'n' here?

サインインしてコメントする。

採用された回答

Dr. Seis
Dr. Seis 2012 年 3 月 7 日
If the code is setup exactly the way you say above, then there is only one element in "f" and one element in "X". You need to do something like this instead:
% Define m and n
f = 1:100:100000;
X = zeros(size(f)); % Preallocate
for ii=1:numel(f)
X(ii)= m*((sin(pi*f(ii)/2*m)*sin(pi*f(ii)/n))/pi*f(ii)*cos(pi*f(ii)/2*m))^2;
end
Or... skip the for loop
X = m*((sin(pi*f/2*m).*sin(pi*f/n))/pi.*f.*cos(pi*f/2*m)).^2;
Then
plot(f,X)
  3 件のコメント
Nicolas
Nicolas 2012 年 3 月 8 日
hello elige!!
now, I am doing something similar but I am getting an error cause of the difference vectors length but look what I wrote, so I dont know where is the mistake
Tc=1*10^-3;
a=1:100:1000000;
R=zeros(size(a));
for f=1:numel(a)
R(f)=i*Tc*sinc(f*Tc/2)*sin(pi*f*Tc/2);
end
plot(a,R);
where i is the imaginary unit
Dr. Seis
Dr. Seis 2012 年 3 月 8 日
You are using "f" inside your sinc and sin functions, but I think you meant to use "a(f)" instead.

サインインしてコメントする。

その他の回答 (1 件)

Thomas
Thomas 2012 年 3 月 7 日
try the following:
define m and n;
m=1;
n=1;
format long
for f=1:100:100000;
X=[X m*((sin(pi*f/2*m)*sin(pi*f/n))/pi*f*cos(pi*f/2*m))^2];
end
plot(f,X)
  1 件のコメント
Nicolas
Nicolas 2012 年 3 月 8 日
Hi!
The code that you gave me had a problem, but I solved. Thanks a lot anyway

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGet Started with Signal Processing Toolbox についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by