matlab实现插值法sin函数
2015-07-09 23:44
661 查看
插值法实现sin函数:
%calculate and print the sine function %input: x %output: sin(x) similar function y = sin2(x) %save a copy of x x_temp = x; %calculate the interpolation polynomial %save the coefficient n = 4; b = pi/4 + (pi/4)*cos((1:2:2*n-1)*pi/(2*n)); yb = sin(b); c = newtdd(b, yb, n);c %for any x, exchange it to base %interpolation method calculation len = size(x, 2); s = ones(1, len); y = zeros(1, len); for i = 1 : len if x(i) < 0 s(i) = s(i) * -1; x(i) = x(i) * -1; end x1(i) = mod(x(i), 2*pi); if x1(i) > pi x1(i) = 2*pi-x1(i); s(i) = s(i) * -1; end if x1(i) > pi/2 x1(i) = pi - x1(i); end y(i) = s(i) * nest(n-1, c, x1(i), b); end plot(x_temp, y); grid on title('sin2(x)'); end
相关文章推荐
- Matlab去掉右面、上面的小短线(ticks)
- matlab实现共轭梯度法、多元牛顿法、broyden方法
- matlab实现雅可比、高斯塞德尔、后项误差计算
- matlab实现高斯消去法、LU分解
- matlab实现不动点迭代、牛顿法、割线法
- matlab实现的嵌套乘法、高精度、二分法
- [图像]图像灰度均衡化和灰度直方图(Matlab实现)
- [图像]获取图片中感兴趣区域的信息(Matlab实现)
- matlab GUI常用文件操作对话框
- 关于matlab信号发展趋势的识别并读取fig文件代码
- matlab norm 范式
- Matlab norm 用法小记
- [图像]用Matlab在图像上画矩形框
- 时间序列分析的matlab自相关函数autocorr
- 关于matlab读取txt文件与连接离散点的函数
- VS和matlab混合编程的推荐书籍!
- matlab里cell和char,字符串与字符数组
- MATLAB函数大全
- Visual Studio中调用matlab生成的dll
- matlab的cell数组