tags:

views:

270

answers:

5
+1  Q: 

Curves in matlab

Just wanted to know if matlab had a function to plot curves instead of lines. Thank you in advance.

A: 

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

Robert Harvey
OP asked for plotting curves, not fitting curves.
Jason S
Well if you're gonna plot it, you gotta fit it first either way. It all comes down to linear segments at the bottom ... the detail is only whether you're determining what's in between or some intrinsic function.
ldigas
A: 

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

hhafez
there's a "spline" function (http://www.mathworks.com/access/helpdesk/help/techdoc/ref/spline.html) but it is curve-interpolating, not plotting. (is there a "splines" function?)
Jason S
but if you can interpolate it, shouldn't you be able to plot it?
Doresoom
defintly, but the question I believe was not worded correctly, yet everyone understood what he meant ;) The questioner said he wants to plot a curve while in reality he already had a set of points that he wanted to plot smothely (for example using splines)
hhafez
+3  A: 

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.

woodchips
+4  A: 

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

Amro
A: 

Have you tried the Curve Fitting Toolbox?

Chris Arnold

related questions