Clear Filters
Clear Filters

Intercept of two polynomial of degree 2 graphs

3 views (last 30 days)
i plotted two graphs, then using 'fit' function i interpolated to polynomial degree two. i can see the point of interception. But i want a function that wil calculate the values of X & Y at which both graphs inrecepts.
See the matlab code and the graph
%Plot the Q-H, Q-P, Q-n graph from the data set.
X1=xlsread('PAT Raw Lab data_plot.xlsx','N2:N331'); % x-axis column for time duration in weeks
Y1=xlsread('PAT Raw Lab data_plot.xlsx','O2:O331');
Z1=xlsread('PAT Raw Lab data_plot.xlsx','R2:R331');
Z2=xlsread('PAT Raw Lab data_plot.xlsx','S2:S331');% y-axis column for weekly ave windspeed (m/s)
figure(1)
f1=fit(X1,Y1,'poly2');
f2=fit(X1,Z2,'poly2');
yyaxis left
p1=plot (f1,X1,Y1,'c*');
ylabel ('Head (H)');
hold on
yyaxis right
p2=plot(f2,X1,Z2,'b*');
hold off
title (' Q-H, & Q-n Characteristic Curve');
xlabel ('Discharge (Q)');
ylabel ('Efficiency (n)');
legend ('Q-H data','Poly deg2 curve','Q-n','Poly deg2 curve');
Please, how can i get the corresponding value of the interception on the Y and X axis?

Answers (1)

darova
darova on 15 Apr 2020
Try this (not tested)
  2 Comments
Alexander Abadom
Alexander Abadom on 15 Apr 2020
Edited: darova on 15 Apr 2020
Please see the result of running your advice
>> g1=fsolve(@(x)f1(x)-f2(x),6);
No solution found.
fsolve stopped because the problem appears regular as measured by the gradient,
but the vector of function values is not near zero as measured by the
default value of the function tolerance.
<stopping criteria details>
However, from the graph i attached i can see that the fit curve intercepts but i need the exact point with accuracy of where it intercepts???
darova
darova on 15 Apr 2020
Didn't realized that you have 2 different Y axes. It's because the curves don't intersect actuallly

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!