How to find X and Y coordinates of maximum gap between curves?
Afficher commentaires plus anciens
Please see the attached figure. In this figure, I want to find the values of X and Y coordinates where the two curve has maximum separation in Y-direction. In this figure, we can see that maximum gap is somewhere around 0.7 in the x-scale.
To do so, I simply take the subtraction of red data and blue data and obtain the gap value and corresponding X-value.
The gap value is delta Y is 6.7*10^7 and X-value is 0.027451.
However, the gap is not maximum at X = 0.027451. So, is there any way I can find the X-Y values of maximum gap between curves?

The data is also attached here with. It may not be same dataset as shown in figure, but a similar data.
I attach fig file for the same data for refrence.
Here is the code to obtain this type of plot.
But how to find maximum gap between curves?
clear; close all
load('rd.mat');
load('bl.mat');
X = flux1.vapa_flx_E
plot(X,rd,'-or');
hold on;
plot(X,bl,'-ob');
set(gca,'YScale','log','YTick',[10^2 10^3 10^4 10^5 10^6 10^7 10^8 10^9 10^10 10^11],'LineWidth',1.5,'FontWeight','bold',...
'FontSize',14, 'YTicklabel',{'10^2','','10^4','','10^6','','10^8','','10^1^0',''});
dif1 = rd-bl;
[val_maxdif1, idx_maxdif1] = max(dif1);
delta_y = val_maxdif1;
x1 = X(idx_maxdif1);
Any help is greatly appriciated.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Graphics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



