开发者

Curves in matlab

开发者 https://www.devze.com 2022-12-13 20:59 出处:网络
Just wanted to know if matlab had a function to pl开发者_JAVA百科ot curves instead of lines. Thank you in advance.No. Not at all. Just plot a set of many points, using connect-the-dots. Use enough poi

Just wanted to know if matlab had a function to pl开发者_JAVA百科ot curves instead of lines. Thank you in advance.


No. Not at all. Just plot a set of many points, using connect-the-dots. Use enough points to get the accuracy you want. Any curve that you can plot will be well represented by such a piecewise linear plot anyway, if you use a fine enough set of points.

If all that you have are a set of points, then use a spline to interpolate them smoothly to get a nice smooth looking curve. Spline, interp1, pchip, or the splines toolbox will help you in this task.


An example of using spline to interpolate then plot the result:

x = 0:2:6*pi;
y = sin(x);
plot(x,y, 'b-'), hold on

xx = 0:0.1:6*pi;
yy = spline(x,y,xx);
plot(xx, yy, 'r-', 'linewidth',2)

screenshot http://www.freeimagehosting.net/uploads/2180c0813b.png


Yes, MATLAB proves a suite of "easy" (= "ez") plotting functions. For example:

ezplot:

ezplot('x^2 - y^2')

and ezsurf:

fh = @(x,y) sqrt(x.^2 + y.^2);
ezsurf(fh)

See http://www.mathworks.com/help/techdoc/ref/ezplot.html for more information


Curve Fitting with Matlab http://www.swarthmore.edu/NatSci/echeeve1/Ref/MatlabCurveFit/MatlabCftool.html


If you are looking for something like splines then yes, just use the spline function


Have you tried the Curve Fitting Toolbox?

0

精彩评论

暂无评论...
验证码 换一张
取 消