用matlab画正弦平滑曲线而不是锯齿线
来源:互联网 发布:大排畸b超数据分析 编辑:程序博客网 时间:2024/06/11 18:28
%{ This is comment.
2016-07-17 Sunday, Im working at WanGen CDN inc. I saw a pic days ago in
the Enterprise QQ Group named CDN JiShu of the company, it is a pic of
a curve of a data sequence, I noticed that it is different to normal
data curve for that it use sinusoidal curve instead of beeline, I feel
it is a creative method to let the curve look more smooth and less
sawtoothly.
This function receive two sequence as input arguments, ABSx is x axis,
ABSy is y asix.
function abPlotSin draws a semi cosine curve between two point, function
abFluentPlot call function abPlotSin to draws semi cosine curve between
every two neighbor points of the point sequence determined by ABSx and
ABSy.
Usage example:
x = 1:10;
s = rand(1, 10);
abFluentPlot(x, s);
%}
function abFluentPlot(ABSx, ABSy)
if length(ABSx) ~= length(ABSy)
return;
end
if length(ABSx) == 1
return;
end
%{ This is comment.
ABPlotX, ABPlotY, The x axis and y axis sequence used to draw
%}
ABPlotX = ABSx(1):(ABSx(end)-ABSx(1))/((length(ABSx)-1)*100):ABSx(end);
ABPlotY = ABPlotX;
for ABI = 1:(length(ABSx) - 1)
ABPoint1 = [ABSx(ABI), ABSy(ABI)];
ABPoint2 = [ABSx(ABI+1), ABSy(ABI+1)];
[ABTmpX1, ABTmpY1] = abPlotSin(ABPoint1, ABPoint2);
ABSubX1 = 1+(ABI-1)*100:1+ABI*100;
ABPlotY(ABSubX1) = ABTmpY1;
end
plot(ABPlotX, ABPlotY, 'color', [0, 0, 0]);
hold on;
%{ This is comment.
The traditional beeline curve for compare with this smooth sinusoid curve
%}
plot(ABSx, ABSy, 'color', [0.5, 0.5, 0.5]);
hold off;
function [sx, sy] = abPlotSin(x1, x2)
%{ This is comment.
make sure that the x1 is at left and x2 at right.
%}
if x1(1) > x2(1)
[x1(1), x2(1)] = abSwap(x1(1), x2(1));
[x1(2), x2(2)] = abSwap(x1(2), x2(2));
end
widx = x2(1) - x1(1);
widy = abs(x2(2) - x1(2));
sx = x1(1):widx/100:x2(1);
if x1(2) > x2(2)
%{ This is comment
widy pi x1(2) - x2(2)
sy = ----- * cos(------ * (sx - x1(1))) + -------------- + x2(2)
2 widx 2
%}
sy = (widy/2)*cos((pi/widx) * (sx - x1(1))) + (x1(2)-x2(2))/2+x2(2);
else
%{ This is comment
widy pi x2(2) - x1(2)
sy = ----- * cos(----- * (sx - x1(1)) + pi) + --------------- + x1(2)
2 widx 2
%}
sy = (widy/2)*cos((pi/widx) * (sx - x1(1)) + pi) + (x2(2)-x1(2))/2 + x1(2);
end
%{ This is unused code.
figure;
plot(sx, sy);
%}
function [x1, x2] = abSwap(x1, x2)
t = x1;
x1 = x2;
x2 = t;
- 用matlab画正弦平滑曲线而不是锯齿线
- matlab 曲线平滑
- MATLAB绘制平滑曲线
- matlab绘制平滑曲线
- MATLAB曲线平滑的办法
- Matlab画平滑曲线的两种方法
- matlab画平滑曲线的两种方法
- 画平滑曲线 & 曲线加粗
- Qt画平滑曲线
- swing 画平滑曲线
- 怎么用U3D画 平滑曲线(贝塞尔曲线)
- 如何使用MATLAB绘制平滑曲线
- matlab利用描点画平滑曲线
- 用VB绘制正弦动画曲线
- Matlab画平滑曲线的两种方法( 拟合或插值后再用plot即可)
- Matlab画平滑曲线的两种方法( 拟合或插值后再用plot即可)
- 绘制正弦函数曲线
- 打印正弦余弦曲线
- 哪些字段适合建立索引?
- hdu-3038-How Many Answers Are Wrong-带权并查集
- 腾讯云:服务器资源池化技术发展趋势
- Android 高德地图API学习笔记(2)
- ajax
- 用matlab画正弦平滑曲线而不是锯齿线
- WeakHashMap类源码解析
- C语言 程序 打印日历
- 自己第一个Android作品,Android计算器
- 【9403】十进制转换八进制数
- Apache Spark DataFrames入门指南:创建DataFrame(2)
- padding 不把盒模型撑开
- 关于group by子句的作用描述正确的是?
- 74. Search a 2D Matrix