Effacer les filtres
Effacer les filtres

Extrapolation of data points

3 vues (au cours des 30 derniers jours)
LB
LB le 23 Sep 2016
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 :)

Réponse acceptée

Star Strider
Star Strider le 23 Sep 2016
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

Plus de réponses (0)

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by