Hello! We have an assignment that involves some fft coding and we have some issues. The teacher gave us a code that should work, but since it's corona times and it's hard to reach him, we mostly have to solve problems using google nowadays.
The code we have, where y and fs are given vectors
Y = abs(fft(y));
N = length(Y);
frekvens = fs*(0:(N/2))/N;
y = 2*abs(fft(Y))/N;
But we get this error message: Warning: Integer operands are required for colon operator when used as index. In this line of code: plot(Y(1:length(Y)/2));
I have googled it and it says that we should make it into an integer or something when using colons and parenthesis (floor,ceil,fix,round) but I don't know how to use it properly, or it might be another problem.
The second task seems a bit harder imo. And if you feel that you have the time to read the question and help me and my mates, that would be hugely appreciated!
In the file arn_passengers.mat is the number of passengers arriving and departing at Arlanda airport north of Stockholm. The data is assembled as date (year and month) and passengers per month. Investigate the data by plotting it. The plot show that there is a bias which is quite large as well as close to linear increase in number of passengers per month. Use fft to determine the period in months for two cases: with bias and linear trend as well as without linear trend and bias. To remove the linear trend and bias you may use the Matlab function detrend
I wrote this code, but I don't know if it's even remotly close to being correct:
D = Date;
Pass = Passengers;
Det_Pass = detrend(Passengers);
NFFT=10000; %NFFT-point DFT
X2=fft(Pass,NFFT); %compute DFT using FFT
nVals=0:NFFT-1; %DFT Sample points
Thanks in advance and best regards,