Sampling data at x_n=cos(n*pi/N) for fft derivative

1 回表示 (過去 30 日間)
Ole
Ole 2021 年 8 月 14 日
コメント済み: Ole 2021 年 8 月 14 日
I am trying to find the derivative of nonperiodic function with chebyshev polynomials.
The function below is from 'Spectral methods in Matlab'. It expects that the vector v is sampled at x_n=cos(n*pi/N).
x = linspace(1,10,10);
y = rand(1,10)*10;
How to sample y at x_n = cos(n*pi/N) assuming domain [-1,1]
function w = chebfft(v)
N = length(v)-1; if N==0, w=0; return, end
x = cos((0:N)'*pi/N);
ii = 0:N-1;
v = v(:); V = [v; flipud(v(2:N))]; % transform x -> theta
U = real(fft(V));
W = real(ifft(1i*[ii 0 1-N:-1]'.*U));
w = zeros(N+1,1);
w(2:N) = W(2:N)./sqrt(1-x(2:N).^2); % transform theta -> x
w(1) = sum(ii'.^2.*U(ii+1))/N + .5*N*U(N+1);
w(N+1) = sum((-1).^(ii+1)'.*ii'.^2.*U(ii+1))/N + ...
.5*(-1)^(N+1)*N*U(N+1);

回答 (1 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021 年 8 月 14 日
I'd see here to use logical indexing for sampling. E.g.:
N=10; y=rand(1,N)*10;
x_n = cos((0:N)'*pi/N);
Y_Sampled=y(x_n>=0);
  1 件のコメント
Ole
Ole 2021 年 8 月 14 日
It should be interpolated in general data. What I do not get is x_n is from 1 to -1.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeFourier Analysis and Filtering についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by