Azzera filtri
Azzera filtri

How to find the best point (of intersection) of 3 contour lines?

9 visualizzazioni (ultimi 30 giorni)
I have made 3 contour maps using the values in data file attached. The 3 contour lines, with values 7.54, 42.38 and 33.46 (as shown in the plot), are intersecting with each other but not altogether. Is there a way to find a common point (with x-y coordinates) which can be called as the intersection of these 3 lines? Your help will be much appreciated. Thank you
load data
contourf(x1,y1,z1, [900 7.54] ,'ShowText','on',FaceAlpha=0.2,EdgeAlpha=0.5,EdgeColor='r');
% 900 value I have input as a dummy value, as when I use only one value, it
% does not show correct contour.
hold on
contourf(x1,y1,z2, [900 42.38] ,'ShowText','on',FaceAlpha=0.2,EdgeAlpha=0.5,EdgeColor='g');
contourf(x1,y1,z3, [900 33.46] ,'ShowText','on',FaceAlpha=0.2,EdgeAlpha=0.5,EdgeColor='b');
grid on
plot(114,135,'x','color','r') % this point is only for demonstration
  3 Commenti
UH
UH il 8 Giu 2023
I have not worked on this yet, but I am aiming along the lines of weighted mean.
John D'Errico
John D'Errico il 8 Giu 2023
Modificato: John D'Errico il 8 Giu 2023
There is no "best" point. Only you can define that. And once you do define what "best" means, then you can START to find a solution. Until then, best is meaningless. Effectively, you cannot even start to write code until you define what the code should do.
You say you are "aiming along the lines of weighted mean". I'm sorry, but this is still a meaningless statement. A weighted mean of what? Where would weights come from in this context?
There is a set of infinitely many points delineated by those contour lines. That set is not even a simple convex set. Certainly not even a triangular region. It is just a region in the plane. Any point inside that region could arguably be identified as best.
And for example, you might pick the centroid of the region. But if a region is not convex, then the centroid need not even be inside the region. (Consider a U-shaped region, and it need not even be that dramatically shaped. Even something that looks like a half moon would qualify as one where the centroid is not contained inside the region itself.)
I'm sorry, but the simplest solution is to just pick the point that makes sense to you. Click with your mouse at a point that makes you happy. That will be as good as any other measure we could offer.

Accedi per commentare.

Risposta accettata

UH
UH il 9 Giu 2023
Spostato: Rik il 9 Giu 2023
@Rik and @John D'Errico Thank you for your feedback and comments. Please forgive my lack of knowledge. Probably I poorly phrased the question. Well, I tried what @John D'Errico suggested in the last paragraph. I found a way out, and will share.
I saved contourf fundtion in a variable. This variable has 2 arrays with initial elements in each array not the coordinate. I found x,y coordinates of each contour. It was simple then, I used polyxpoly to find the intersection of each pair of contours. Then I took the mean. This procedure I can work further on.
Thank you for your help.
load data
[c1]=contourf(x1,y1,z1, [900 7.54] ,'ShowText','on',FaceAlpha=0.2,EdgeAlpha=0.5,EdgeColor='r');
% 900 value I have input as a dummy value, as when I use only one value, it
% does not show correct contour.
hold on
[c2] = contourf(x1,y1,z2, [900 42.38] ,'ShowText','on',FaceAlpha=0.2,EdgeAlpha=0.5,EdgeColor='g');
[c3] = contourf(x1,y1,z3, [900 33.46] ,'ShowText','on',FaceAlpha=0.2,EdgeAlpha=0.5,EdgeColor='b');
grid on
c1 = c1';c2= c2'; c3 = c3';
c1(1,:) = [];c2(1,:) = [];c3(1,:) = [];
[x1,y1] = polyxpoly(c1(:,1),c1(:,2), c2(:,1),c2(:,2));
[x2,y2] = polyxpoly(c1(:,1),c1(:,2), c3(:,1),c3(:,2));
[x3,y3] = polyxpoly(c2(:,1),c2(:,2), c3(:,1),c3(:,2));
avgx = mean([x1 x2 x3]);
avgy = mean([y1 y2 y3]);
plot(avgx,avgy,'ro')

Più risposte (0)

Categorie

Scopri di più su Contour Plots in Help Center e File Exchange

Prodotti


Release

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by