spectrum(x, log=”no”,span=5, plot=FALSE) similar command in Matlab.
My Matlab code is like following:
del = 1/120; % lenght of sampling interval
subplot(3,1,1)
I= pop(:,2);
I1= I(4801:end)/10000;
plot(t(4801:end),I1,LineWidth=1.5);
xlabel ‘Time’;
ylabel ‘Infectious population, I’;
subplot(3,1,2)
S = abs(fft(I1));
L = length(S);
S_oneside= S(1:L/2);
f = (1/del)*(0:L/2-1)/L; %frequency question
S_meg=abs(S_oneside)/(L/2);
P=findpeaks(S_meg);
plot(f,S_meg,LineWidth=1.5);
xlabel ‘Frequency’;
ylabel ‘Spectral density’;
subplot(3,1,3)
plot(f,S_meg,LineWidth=1.5)
xlim([0.1 2])
xlabel ‘Frequency’;
ylabel ‘Spectral density’;
This gives me the correct graph. But in R for smoothing they use span = 5, how can I smooth the peaks in Matlab?My Matlab code is like following:
del = 1/120; % lenght of sampling interval
subplot(3,1,1)
I= pop(:,2);
I1= I(4801:end)/10000;
plot(t(4801:end),I1,LineWidth=1.5);
xlabel ‘Time’;
ylabel ‘Infectious population, I’;
subplot(3,1,2)
S = abs(fft(I1));
L = length(S);
S_oneside= S(1:L/2);
f = (1/del)*(0:L/2-1)/L; %frequency question
S_meg=abs(S_oneside)/(L/2);
P=findpeaks(S_meg);
plot(f,S_meg,LineWidth=1.5);
xlabel ‘Frequency’;
ylabel ‘Spectral density’;
subplot(3,1,3)
plot(f,S_meg,LineWidth=1.5)
xlim([0.1 2])
xlabel ‘Frequency’;
ylabel ‘Spectral density’;
This gives me the correct graph. But in R for smoothing they use span = 5, how can I smooth the peaks in Matlab? My Matlab code is like following:
del = 1/120; % lenght of sampling interval
subplot(3,1,1)
I= pop(:,2);
I1= I(4801:end)/10000;
plot(t(4801:end),I1,LineWidth=1.5);
xlabel ‘Time’;
ylabel ‘Infectious population, I’;
subplot(3,1,2)
S = abs(fft(I1));
L = length(S);
S_oneside= S(1:L/2);
f = (1/del)*(0:L/2-1)/L; %frequency question
S_meg=abs(S_oneside)/(L/2);
P=findpeaks(S_meg);
plot(f,S_meg,LineWidth=1.5);
xlabel ‘Frequency’;
ylabel ‘Spectral density’;
subplot(3,1,3)
plot(f,S_meg,LineWidth=1.5)
xlim([0.1 2])
xlabel ‘Frequency’;
ylabel ‘Spectral density’;
This gives me the correct graph. But in R for smoothing they use span = 5, how can I smooth the peaks in Matlab? spectrum analysis MATLAB Answers — New Questions