How to find the range of a contour along each dimension of a plane with least possible error?

1 vue (au cours des 30 derniers jours)
I have a matrix of data which I plotted as a contour using the contour function. The y-axis of the plot is taken as log of the variable, i.e. I used:
contour(x,log2(y),Data,[-99,1],'k');
The resulting plot has an irregular shape. By "irregular" I mean that it's not a nice smooth elliptical or rectangular shape, it's quite jagged at places and not evenly spread everywhere. I am posting one such plot below.
Here, I want to find out the left most point and the right most point of this contour to find the range along x-axis. Similarly, I want to find the bottom most point and the top most point of this contour to find the range along y-axis. Obviously for such shape, the x coordinates of the y_bottom and y_top will be different; y coordinates of the x_left and x_right will be different.
So, how do I find out the four points? One way is to do it by observation and select the points myself to note down the values, but there is a chance of error there. How to find it exactly with code?
Also I have another minor doubt: since I have used log2 of the y data, is there any way to minimize approximation error that I should be careful about?

Réponses (1)

KSSV
KSSV le 10 Juil 2023
C = contour(x,log2(y),Data,[-99,1],'k');
x = C(1,:) ;
y = C(2,:) ;
iwant = [min(x) min(y) ;
max(x) min(y) ;
max(x) max(y) ;
min(x) max(y)] ;
  7 commentaires
Sourin
Sourin le 20 Juil 2023
Modifié(e) : Sourin le 20 Juil 2023
@Walter Roberson Would you write this as answer in a separate comment? This is working without any error. It works on a single contour or multiple ones as well. If you post as a separate answer, I will be able to accept it as answer to my question. So other users can see it easily later.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Contour Plots dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by