matlab 绘制双三次插值函数曲线

想要的效果:

编程时要用到分段函数曲线的绘制方法:..+.*(分段条件)。

插值法处理图像包含最近邻,双线性,双三次插值法处理图像

需要注意的是:函数表达式中的乘除和乘方都要加“.”。因为一般的函数都是数在乘变量运算。

x=-2:0.001:2;
a=-0.5;
w=abs(x);
y=(1.5.*w.^3-2.5.*w.^2+1).*(w<=1)+(-0.5.*w.^3+2.5.*w.^2-4.*w+2).*(w>1&w<=2);
plot(x,y);
box off;
view([1 90]);
xlabel('w');
ylabel('S(w)');

然后想将坐标轴变一下:

新建一个xyplot.m文件:

function xyplot(x,y)
% xyplot Plot 2D axes through the origin
%   Example 1:
%   t = linspace(0,2*pi,500); 
%   y1 = 80*sin(t); 
%   y2 = 100*cos(t);
%   xyplot(t,[y1;y2])
%
%   Example 2:
%   x = -2*pi:pi/10:2*pi;
%   y = sin(x);
%   plot(x,y)
%   xyplot
% PLOT
if nargin>0
    if nargin == 2
     plot(x,y);
    else
    display('Not 2D Data set!')
    end
end
hold on;
% GET TICKS
X=get(gca,'Xtick');
Y=get(gca,'Ytick');
% GET LABELS
XL=get(gca,'XtickLabel');
YL=get(gca,'YtickLabel');
% GET OFFSETS
Xoff=diff(get(gca,'XLim'))./40;
Yoff=diff(get(gca,'YLim'))./40;
% DRAW AXIS LINEs
plot(get(gca,'XLim'),[0 0],'k');
plot([0 0],get(gca,'YLim'),'k');
% Plot new ticks
for i=1:length(X)
    plot([X(i) X(i)],[0 Yoff],'-k');
end;
for i=1:length(Y)
    plot([Xoff, 0],[Y(i) Y(i)],'-k');
end;
% ADD LABELS
text(X,zeros(size(X))-2.*Yoff,XL);
text(zeros(size(Y))-3.*Xoff,Y,YL);
box off;
% axis square;
axis off;
set(gcf,'color','w');

重新调用运行即可:

x=-2:0.001:2;
a=-0.5;
w=abs(x);
y=(1.5.*w.^3-2.5.*w.^2+1).*(w<=1)+(-0.5.*w.^3+2.5.*w.^2-4.*w+2).*(w>1&w<=2);
xyplot(x,y);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值