Extrapolation of data points

3 次查看(过去 30 天)
Hi everyone.
I have calculated and plotted a set of x and y values. Let's say I have 20 points in my figure.
I want to use my first five point to extrapolate backwards to intercept the y-axis.
Can anyone help me with this?
Thank you :)

采纳的回答

Star Strider
Star Strider 2016-9-23
I am not certain exactly what you want.
See if this works for you:
x = sort(rand(1, 20)); % Create Data
y = sort(rand(1, 20)); % Create Data
x_5 = x(1:5);
y_5 = y(1:5);
b = [ones(size(x_5(:))), x_5(:)]\y_5(:); % Estimate Parameters
y_int = b(1); % Y-Intercept
y_xtrp = [ones(size([0; x_5(:)])), [0; x_5(:)]]*b; % Create Line
figure(1)
plot(x, y, 'bp')
hold on
plot([0; x_5(:)]', y_xtrp', '--r')
hold off
grid

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by