contour plot not working because of duplicate value

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.

回答 (1 件)

Varun Garg
Varun Garg 2018 年 6 月 4 日

0 投票

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
intersect
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)
x(ix)=[]
y(iy)=[]
Hope my understanding was right. You can refer documentation here .

11 件のコメント

Samaneh Arzpeima
Samaneh Arzpeima 2018 年 6 月 4 日
編集済み: Samaneh Arzpeima 2018 年 6 月 4 日
Thank you, Varun. The X, Y are the coordinates of a meshed surface and I want to plot the contour of the slip(or time of the slip) for those nodes. But I get an error says that there are some overlapped data. So I think I should have some grids with the same coordinates(same X and Y) , I need to find those rows and delete them.(rows with the same X and Ys and delete the whole row.) I have the coordinates data down to 8 decimal.
*your code didn’t work on MtlanOnline The error was Error in intersect>intersectR2012a (line 220) [c,iau] = unique([a(ia) b([])],order);
Error in intersect (line 111) [varargout{1:nlhs}] = intersectR2012a(varargin{:});
Error in unique (line 8) [z ix iy]= intersect(x,y)
Varun Garg
Varun Garg 2018 年 6 月 4 日
I am trying to imagine it. So basically X and Y are vectors only but they make up a coordinate system with let's say X(1) and X(1) correspond to a point in 2-d plane?
Samaneh Arzpeima
Samaneh Arzpeima 2018 年 6 月 4 日
編集済み: Samaneh Arzpeima 2018 年 6 月 5 日
exactly X(1) and Y(1) correspond to one point.
Varun Garg
Varun Garg 2018 年 6 月 5 日
So what I gather from the information provided is that the mesh can be though of as an AxB matrix let's say M. And if there is a point X(i),Y(i) which can be thought of as M(j,k), if both of the coordinates are same, you want to remover the whole row j?
Samaneh Arzpeima
Samaneh Arzpeima 2018 年 6 月 5 日
編集済み: Samaneh Arzpeima 2018 年 6 月 5 日
vector1
X=rand(90000,1)
vector2
Y=rand(90000,1)
vector3
T=rand(90000,1)
here,point(X,Y) refers to a grid coordinate,
if
X(i,1)=X(j,1)=X(k,1)...
Y(i,1)=Y(j,1)=Y(k,1)...
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.
scatter(d.Y,d.X,5,d.Dz);
[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
Samaneh Arzpeima
Samaneh Arzpeima 2018 年 6 月 5 日
@Varun Garg sorry if I made it complicated ,I am still new in Matlab
Varun Garg
Varun Garg 2018 年 6 月 5 日
It has become a bit confusing. Let me tell you final understanding of your question:
Mathematically, you have a function
f(x,y,t).
And let's say you have two points on the 3-D Plane
f(xi,yi,ti) and f(xj,yj,tj).
If
f(xi,yi,ti) == f(xj,yj,tj)
you want to remove either
f(xi,yi,ti) or f(xj,yj,tj).
Is that so?
Samaneh Arzpeima
Samaneh Arzpeima 2018 年 6 月 5 日
I just rewrite my last question ,it might be a bit more understandable. (^^;)
Samaneh Arzpeima
Samaneh Arzpeima 2018 年 6 月 5 日
vector1
X=rand(90000,1)
vector2
Y=rand(90000,1)
vector3
T=rand(90000,1)
here,point(X,Y) refers to a grid coordinate,
if
X(i,1)=X(j,1)=X(k,1)...
Y(i,1)=Y(j,1)=Y(k,1)...
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.
scatter(d.Y,d.X,5,d.Dz);
[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
Varun Garg
Varun Garg 2018 年 6 月 5 日
Okay. That's a bit better explanation. One more doubt If
X(i,1)=X(j,1)=X(k,1)
and
Y(i,1)=Y(j,1)=Y(k,1)
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?
Samaneh Arzpeima
Samaneh Arzpeima 2018 年 6 月 6 日
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.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeJust for fun についてさらに検索

製品

質問済み:

2018 年 6 月 4 日

コメント済み:

2018 年 6 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by