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

조회 수: 2 (최근 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

댓글을 달려면 로그인하십시오.

답변 (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 CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by