前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >使用切比雪夫多项式应用在逼近理论中。

使用切比雪夫多项式应用在逼近理论中。

作者头像
裴来凡
发布2022-05-28 15:28:02
3490
发布2022-05-28 15:28:02
举报
文章被收录于专栏:图像处理与模式识别研究所

chebyshev.m

代码语言:javascript
复制
% Using Chebyshev Polynomials
clear all; close all; clc;

% Define:
f = @(x) x.^4;
%f = @(x) 4*(x.^2-x.^4).*exp(-x./2);

x = (-1:0.1:1)'; % for -1 <= x <= 1

chebyshevP.m

代码语言:javascript
复制
function chebP = chebyshevP(x,k)
% compute the value of the chebyshev polinomial of degree 'k' for every
% column value 'x'

%number of points
p = k+1;

switch k
    case {0} % when k = 0
        chebP = ones(size(x));
    case {1} % when k = 1
        chebP = x;
    otherwise % k >= 2 
        chebP0 = ones(size(x));
        chebP1 = x;
        for m = 1:k-1
            chebPX = (2*x.*chebP1 - chebP0);
            chebP0 = chebP1;
            chebP1 = chebPX;
        end
        chebP = chebPX;
end

dct_and_dst.m

代码语言:javascript
复制
% Using dcf and dst 
clear all; close all; clc;

f = @(x) x.^2/pi^2;

N = 16; j = 0:N;
x = (2*pi/N)*j;

y = f(x)';

yct = dct(y);
yst = dst(y);

figure(1)
hold on; grid on;
plot(abs(yst),'-or');
plot(abs(yct),'--sg');
legend('dst','dct')
hold off;

FFT_1d.m

代码语言:javascript
复制
% Using FFT 
clear all; close all; clc;

f = @(x) cos(3*x);
%f = @(x) 1*(x>=0 & x<pi) + (-1)*(x>=pi & x<2*pi);

N = 16; j = 0:N-1;

x = (2*pi/N)*j;

y = f(x)';

yt = fft(y);

% Plot coeficients
figure(1)
grid on; plot(abs(yt),'or'); legend('fft')

FFT_1d.m

代码语言:javascript
复制
% Using FFT 
clear all; close all; clc;

f = @(x) cos(3*x);
%f = @(x) 1*(x>=0 & x<pi) + (-1)*(x>=pi & x<2*pi);

N = 16; j = 0:N-1;

x = (2*pi/N)*j;

y = f(x)';

yt = fft(y);

% Plot coeficients
figure(1)
grid on; plot(abs(yt),'or'); legend('fft')

FFT_1d.m

代码语言:javascript
复制
% Using FFT 
clear all; close all; clc;

f = @(x) cos(3*x);
%f = @(x) 1*(x>=0 & x<pi) + (-1)*(x>=pi & x<2*pi);

N = 16; j = 0:N-1;

x = (2*pi/N)*j;

y = f(x)';

yt = fft(y);

% Plot coeficients
figure(1)
grid on; plot(abs(yt),'or'); legend('fft')
本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2020-05-22,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 图像处理与模式识别研究所 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档