The graph wasnt showing the appropiate answer

3 Ansichten (letzte 30 Tage)
Bradley Jason Teguh
Bradley Jason Teguh am 19 Okt. 2021
Kommentiert: Cris LaPierre am 19 Okt. 2021
clc
clear all
Ts=0.1; %Ts=sampling time
Tc=Ts/100; %Tc=continuous time increament
Tr=10; %Tr=record time
A=1; %A=amplitude of vibration
f=1; %f=frequency of signal
%Plot of waveform (continuous and discrete)
t=0.001:Ts:Tr;
x=A*sin(2*pi*1*t)+ A*sin(2*pi*11*t);
tc=0:Tc:Tr;
xc=A*sin(2*pi*1*tc) + A*sin(2*pi*11*tc);
subplot(211)
plot(t,x,'*',tc,xc)
%Find the spectrum of x(kT), so X(iw)=fft(x(k))
Xs=fft(x); %Xs=spectrum of x
%Now we want to plot the magnitude of X(iw), thus |X(iw)|=abs(X(iw))
[k,b]=size(Xs);
N=b;
N2=N/2;
magXs=(2/N)*abs(Xs);
df=1/Tr; %df=Frequency resolution
i=0:(N2-1);
f1=df*i;
subplot(212)
plot(f1,magXs(1,1:N2))
subplot
This is the code and it wont show the right spectrum cause the other spectrum should be at 11 Hz

Antworten (1)

Cris LaPierre
Cris LaPierre am 19 Okt. 2021
You have specificed a sample frequency of 10 Hz (Ts=0.1). Therefore, according the Nyquist criterion, the highest frequency you can resolve is 5 Hz.
  1 Kommentar
Cris LaPierre
Cris LaPierre am 19 Okt. 2021
Change your sample frequency to something at least double the maximum frequency you want to detect, and it will appear.
% v made Ts 10x smaller. Corresponding Fs is now 100 Hz. Can now resolve up to 50 Hz
Ts=0.01; %Ts=sampling time
Tc=Ts/100; %Tc=continuous time increament
Tr=10; %Tr=record time
A=1; %A=amplitude of vibration
f=1; %f=frequency of signal
%Plot of waveform (continuous and discrete)
t=0.001:Ts:Tr;
x=A*sin(2*pi*1*t)+ A*sin(2*pi*11*t);
tc=0:Tc:Tr;
xc=A*sin(2*pi*1*tc) + A*sin(2*pi*11*tc);
%Find the spectrum of x(kT), so X(iw)=fft(x(k))
Xs=fft(x); %Xs=spectrum of x
% Calculate magnitude of X(iw), thus |X(iw)|=abs(X(iw))
[k,b]=size(Xs);
N=b;
N2=N/2;
magXs=(2/N)*abs(Xs);
df=1/Tr; %df=Frequency resolution
i=0:(N2-1);
f1=df*i;
% Plot
subplot(211)
plot(t,x,'*',tc,xc)
subplot(212)
plot(f1,magXs(1,1:N2))

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by