⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch8example17.m

📁 清华大学出版社 邵玉斌编写的《通信系统建模与仿真实例分析》一书的所有MATLAB和SIMULINK代码
💻 M
字号:
% ch8example17.m
x=-1:0.01:1;
y=1./(1+9*x.^2);
plot(x,y,'k');hold on;                 % 原始函数曲线
xs=[-1, -0.4, -0.1,0,0.3,0.7];         % 样本位置
ys=1./(1+9*xs.^2);
plot(xs,ys,'o');hold on;               % 样本点
xi=-1:0.07:1;                          % 插值位置
yi=interp1(xs,ys,xi,'linear','extrap');% 线性插值,并外插
plot(xi,yi,'.');
yi=interp1(xs,ys,xi,'nearest');        % 邻近点插值
plot(xi,yi,'-.');
yi=interp1(xs,ys,xi,'pchip');          % 立方插值
plot(xi,yi,'*');
yi=interp1(xs,ys,xi,'spine');          % 立方插值
plot(xi,yi,'s');
legend('原始函数y=f(x)','样本点','线性插值','邻近点插值','立方插值','样条插值');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -