How can I transform polynomials such that they overlay each other?

1 Ansicht (letzte 30 Tage)
Harm Gilsing
Harm Gilsing am 13 Mai 2022
Bearbeitet: Jon am 13 Mai 2022
I created a plot consisting of 5 polynomials of 2nd degree (see attachment). The coefficients of those polynomials are:
  • p = [-3.790466223990772e-04,0.004074643555077,-0.033133211227356]
  • p1 = [2.463875132721238e-04,3.802876924742511e-04,1.953560252697614e-05]
  • p2 = [2.019059367863187e-04,1.156123725241465e-04,2.614767201627642e-04]
  • p3 = [2.621495684977407e-04,8.229496951057387e-05,2.218464586208243e-04]
  • p4 = [4.451376205036274e-04,-1.027157047259503e-04,5.282799436326823e-04]
Does anyone know if it is possible to transform (4 of) the polynomials in order to let them overlay with each other?
Thanks in advance!
  1 Kommentar
Jon
Jon am 13 Mai 2022
What do you mean by "overlay"? Do you want them to all have the same y value at some particular value of x?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Jon
Jon am 13 Mai 2022
Bearbeitet: Jon am 13 Mai 2022
Assuming you want them to match at some particular value of x you could do something like this.
By the way the first curve in your set of polynomials doesn't seem to look like the one you show in your figure. Maybe some transcription error writing down the coefficients?
% define x value at which curves will match
xMatch = 1;
% define matrix of polynomial coefficients, each row is a polynomial curve
P = [-3.790466223990772e-04,0.004074643555077,-0.033133211227356;
2.463875132721238e-04,3.802876924742511e-04,1.953560252697614e-05;
2.019059367863187e-04,1.156123725241465e-04,2.614767201627642e-04;
2.621495684977407e-04,8.229496951057387e-05,2.218464586208243e-04;
4.451376205036274e-04,-1.027157047259503e-04,5.282799436326823e-04];
% get number of curves for future use
numCurves = size(P,1);
% calculate value of first polynomial at the value of x where curves are to
% match
yMatch = polyval(P(1,:),xMatch);
% loop through curves to compute match
Pmatch = zeros(size(P)); % preallocate
for k = 1:numCurves
% compute offset from first curve at the match point
delta = polyval(P(k,:),xMatch) - yMatch;
% compute corrected coefficients, just modify the constant term
Pmatch(k,:) = [P(k,1:end-1),P(k,end)-delta];
end
% check results
xplot = linspace(0,5);
% original curves
figure
for k = 1:numCurves
plot(xplot,polyval(P(k,:),xplot))
hold on
end
title('original curves')
hold off
% original curves
figure
for k = 1:numCurves
plot(xplot,polyval(Pmatch(k,:),xplot))
hold on
end
title('matched curves')
hold off

Kategorien

Mehr zu Polynomials finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by