This topic has been permanently closed and transferred to MATLAB Answers.

General
Follow


Sushil Kunwar
6 views (last 30 days)

Curve line plot help

Sushil Kunwar on 8 Dec 2023
Latest activity Reply by Walter Roberson on 8 Dec 2023

Hi! I am using matlab inbuilt plot option( without typing code) to plot the data. This joins the data points using straight line by default. What will be the easiest way to plot if I want curve to join the points instead?
Walter Roberson
Walter Roberson on 8 Dec 2023
You cannot do that. Internally, all drawn curves are a series of straight line segments. Internally, all surfaces are descriptions of faces with straight edges, together with face color information.
Images, on the other hand, are raster data that have a different internal implementation.
When I say "internally", I am talking at the graphics library level. OpenGL does not represent curves directly.
All you can do is select points closer together so that to the human eye, the many-short-segments-together looks like a curve.
If your input is just a series of points, without any model function that might allow you to calculate new points, then the create a smoother curve, you need some function to estimate intermediate points. If you use the wrong estimation function, then the curve you come up with might have no mathematical or physical justification, and so might completely misread people looking at the curve.
So, given just a series of existing points, can you (reasonably accurately) calculate what the function that creates the points is? It turns out the mathematical answer is no, absolutely not. If all you are starting with is a finite list of points expressed to finite precision, then there is a literal infinity of functions that will reproduce those points to within round-off error, so the probability that you will select the "right" function is 1 divided by infinity which is zero.
You can use techniques such as polyfit() or you can calculate splines over the existing points, but if you do not have a pre-existing physical or mathematical basis for selecting those, then your output curve will very likely be wrong. Is there any benefit to showing the user a smooth curve that is the wrong curve?

See Also