how to create magnitude spectrum signal based on data from excel

조회 수: 1 (최근 30일)
shila kaimi
shila kaimi 2019년 11월 22일
댓글: Star Strider 2019년 11월 25일
dataset=xlsread('Group3.xlsx','Sheet1','A1:ALM1');
stepsize=0.001;
N=1;
t=0:stepsize:N;
x= dataset;
X=fft(x);
f=size(x,2)/2;
mag_spec=abs(x)/f;
freq=(0:499/2*f*stepsize);
plot(freq,mag_spec(1:500));
i already tried this code, but the error state :
'Error using plot
Vectors must be the same length.'

채택된 답변

Star Strider
Star Strider 2019년 11월 22일
Your code needs a few slight improvements:
dataset=xlsread('Group3.xlsx','Sheet1','A1:ALM1');
stepsize=0.001;
N=1;
t=0:stepsize:N;
x= dataset;
X=fft(x);
f=size(x,2)/2;
mag_spec=abs(X)/(2*f); % Normalise By The Length Of The Original Vector
freq=(0:499*(2*f)*stepsize); % Use Full Vector Length To Create A Compatible Frequency Vector
figure
plot(freq,mag_spec(1:500));
xlim([0 50])
  댓글 수: 2
ahmad syaiful md subri
ahmad syaiful md subri 2019년 11월 25일
From the amplitude spectrum diagram of the signal (codding that you have give), how to design the lowpass filter to extract low frequency signal using Butterworth approximation
Star Strider
Star Strider 2019년 11월 25일
Choose the frequencies you want the filter to select, then follow the instructions in the documentation for buttord, butter, and zp2sos functions. Use filtfilt to do the actual filtering.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Digital Filter Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by