MATLAB Answers


contour plot not working because of duplicate value

Asked by Samaneh Arzpeima on 4 Jun 2018
Latest activity Commented on by Samaneh Arzpeima on 6 Jun 2018
Hello Everybody
I have 3 vectors with 95000 rows. X, Y,and T(time of rupture). Now I need to draw contour using these 3 vectors.but it sounds there are duplicates data(an error message say so! I guess there might be some data with same X and Y ) . I would like to removes them before drawing contour plot. Can anyone help. Thank You for your time.


Sign in to comment.

1 Answer

Answer by Varun Garg on 4 Jun 2018

Hi Samaneh,
My understanding of your question is that for the vectors X and Y you want to find values which are common in both.
For that you can use
Example snippet:
x=[1 2 3 4 5 10 20 30];
y=[4 5 10 100 90 22 33];
[z ix iy]= intersect(x,y)
Hope my understanding was right. You can refer documentation here .


here,point(X,Y) refers to a grid coordinate,
I need to keep just one of the repeated grid point,for example keep the row(i), and delete row(j) and (k).when I have same grid data even with different T.
what I actually have
vector1 d.X 90000*1 coordinat
vector2 d.Y 90000*1 coordinat
vector3 d.Dz 90000*1 time of slip for each grid
I wrote something like this to get the graph that I attached here, I ignored the repeated data point for this graph though.
[X,Y] = meshgrid(linspace(min(d.Y),max(d.Y),80), linspace(min(d.X),max(d.X),80));
hold on
[C,h]=contour(X,Y,griddata(d.Y,d.X,d.Dz,X,Y),[10 8 6 4 1 ])
I want to delete the repeated data and replot
if I am not clear ,excuse me,and just ignor.sorry for the time
Okay. That's a bit better explanation. One more doubt If
Should they both hold true together for me to keep only i row and delete j,k.. Or any of (1) or (2) hold true, I should delete j,k.. from both X and Y?
Thamk you again
I just need one set of (x,y) to have one value of time or slip. for a point with coordinate lets say (x=2,y=3) if I have 3 value for time like
x y t
2 3 3
2 3 2
2 3 5
I want to keep point(2,3) with the lowest time, so I have to delete first and third row.

Sign in to comment.