Sir how to multiply a square wave and sinewave and generate power spectrum from the output of those singnal

1 回表示 (過去 30 日間)
sir i tried it i have that code
this is my code sir please correct my code sir i am getting errors regarding matrix
t=0:1:40;
f=500;
fs=8000;
x=sin(2*pi*f/fs*t);
figure(1);
stem(t,x,'r');
figure(2);
stem(t*1/fs*1000,x,'r');
hold on;
plot(t*1/fs*1000,x);
fftLength = 1024;
sigLength = length(x);
win = rectwin(sigLength);
y=fft(x.*win,fftLength);
figLength=fftLength/2+1;
plot([1:figLength]*fs/(2*figLength),abs(y(1:figLength)));
plot([1:figLength]*fs/(2*figLength),20*log10(abs(y(1:figLength))));
  3 件のコメント
Naga Sai
Naga Sai 2017 年 5 月 22 日
how to create an own fft function in matlab sir please help me in this case
Walter Roberson
Walter Roberson 2017 年 6 月 8 日
Naga Sai comments to me:
so what run the code

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

回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 6 月 8 日
Change
y=fft(x.*win,fftLength);
to
y=fft(x(:).*win(:), fftLength);
If you had "Please copy the entire error message -- everything in red." when requested then this could have been solved two weeks ago. The code you posted does not give an error in R2016b or later; if you had posted the error message then I would have immediately known that you are running R2016a or earlier and would have been able to suggest the solution.
"how to create an own fft function in matlab sir please help me in this case"
There are numerous posts in which people have implemented discrete fft. Search for them.

カテゴリ

Help Center および File ExchangeFourier Analysis and Filtering についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by