Mercurial > repos > public > sbplib
comparison four.m @ 704:111fcbcff2e9 feature/optim
merg with featuew grids
author | Ylva Rydin <ylva.rydin@telia.com> |
---|---|
date | Fri, 03 Nov 2017 10:53:15 +0100 |
parents | f6ada1719420 |
children |
comparison
equal
deleted
inserted
replaced
703:027f606fa691 | 704:111fcbcff2e9 |
---|---|
1 % four returns the fourier transform u_hat of the function u and the frequencies w | |
2 function [w, u_hat] = four(x, u) | |
3 u_hat = fft(u); | |
4 | |
5 N = length(x); | |
6 L = x(end) - x(1); | |
7 | |
8 k = shift_k(0:N-1); | |
9 | |
10 u_hat = fftshift(u_hat); | |
11 | |
12 dw = 2*pi/L; | |
13 w = dw*k; | |
14 end | |
15 | |
16 function k_shifted = shift_k(k) | |
17 N = length(k); | |
18 k_shifted = [-floor(N/2):-1, 0, 1:ceil(N/2)-1]; | |
19 end |