Automatically continue a line
7 次查看(过去 30 天)
显示 更早的评论
Hi there
Is there any way for automatically continue a drawed line?
For example, we have a curved line, and we want to extend it.
In example the black one, to below
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/730724/image.png)
Thank you!
4 个评论
Ravi Narasimhan
2021-9-7
My recommendation does not make sense if you are looking for a way to extend general curves especially if they are based on real data.
I use extrapolation only for small regions outside my data and then only if I have some underlying model for the data points; e.g. linear or exponential decay, growth, and so forth that are consistent with Matlab's inter/extrapolation algorithms.
You can consider fitting a curve to your points and then extrapolating from there if justified to do so.
@Jan brings up very good reasons/examples as well.
回答(1 个)
Jan
2021-9-7
编辑:Jan
2021-9-7
This cannot work without further assumptions. Because the existing line is drawn with some noise, e.g. due to rounding effects, there is an infinite number of curves matching a finite section of the original curve. If you have a sufficiently small piece of the curve, there is no chance to indentify, if it is a circle, parabola, sine, tangent or a straight line.
Remember that e.g. the extrapolation of a curve by a polynomial is extremely instable for higher orders.
Imagine a straight line drawn with a pencil on paper. It looks trivial to identify this as a line and to continue it. But how do you decide in which magnitude and over which length you determine the slope? Looking with a mikroscope on the final micrometer you will see a huge colored block. So you have to take a magnification, in which the width of the line is "sufficiently" smaller than its length. Even then you can take the right and the left edge of the line such that the determination of the slope has an uncertainty.
This effect does not only appear for real lines drawn on paper, but for numerical data stored with limited precision in a computer also.
Of course, if you do know in advance, that the line is a sine, you can use the existing data points to determine the parameters. But in general you do not know the equation. Assume you get the coordinates of the curve at the red circles:
x = linspace(0, 9*pi, 100);
y = sin(x);
plot(x, y, 'ro'); hold('on');
Of course you could decide, that this is a sine wave, but this equation matchs the given points very good also:
xx = linspace(0, 10*pi, 1000);
yy = sin(xx) + exp(xx - 9.8*pi);
plot(xx, yy, 'b')
If you have the rightmost 4 points only, assuming that this is a straight line or a sine wave would be pure guessing. The more points you have, the more possible solutions can be excluded. But the problem remains that infinity minus a huge number is still infinity. Because an infinite number of possible curves matchs a set of given points recorded with a limited precision, you cannot guess reliably, how a section of a curve has to be extrapolated.
Is there any way for automatically continue a drawed line?
It depeneds. If you decide for a specific scale and take a specific number of "points" to obtain the parameters of a specified formula (e.g. a sine or a straight line), you can determine the parameters with a deviation, such that you can draw a "most likely" continuation together with a (in general exponentially) growing uncertainty interval.
The job seems to be very easy for human. Give a 5 year old child a pencil and it will solve this for you without noticing, that the problem is hard. But from a viewpoint of a scientist, it gets clear, that the child included a huge number of intelligent assumptions based on common sense like "healthy curves do not explode or drive around like crazy". Almost all real curves does.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interpolation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!