# 2D plot of deformation data

3 Ansichten (letzte 30 Tage)
Sara am 6 Mär. 2023
Kommentiert: William Rose am 7 Mär. 2023
Hi,
I have txt file with information of x and y coordnates and c as color data and u,v as defromation data which is for displacment.
I want to plor the 2D of the displacment with its color. what I was able to do is plot the data with no defromation, displacment, as shown in the image
my code is after I load the data.
x = data(:,1);
y = data(:,2);
c = data(:,3);
U = data(:,4);
V = data(:,5);
n = 500
[X, Y] = meshgrid(linspace(min(x),max(x),n), linspace(min(y),max(y),n));
ColorData = griddata(x,y,c,X,Y);
pcolor (X,Y,ColorData);
When I used the U and V I got this image
##### 5 Kommentare3 ältere Kommentare anzeigen3 ältere Kommentare ausblenden
Sara am 7 Mär. 2023
what I ment is switching the code from
ColorData = griddata(x,y,c,X,Y);
to
ColorData = griddata(U,V,c,X,Y);
but I will try to do your code in my code and see what will happen
Thank you
William Rose am 7 Mär. 2023
You said you wante d to switch the code from
ColorData = griddata(x,y,c,X,Y);
to
ColorData = griddata(U,V,c,X,Y);
I don;t think this will do what you want, because griddata is a 2D interpolation routine. In the first form, it assume you measured c at points x and y, and it interpolates those measurements to the gird X,Y. But U,V are not measurement locations - they are measured values.

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

Mathieu NOE am 6 Mär. 2023
hello again
basically used the same code for U and V and got these 3 plots
for ColorData
for U
for V
code :
x = data(:,1);
y = data(:,2);
c = data(:,3);
u = data(:,4);
v = data(:,5);
n = 500;
[X, Y] = meshgrid(linspace(min(x),max(x),n), linspace(min(y),max(y),n));
ColorData = griddata(x,y,c,X,Y);
U = griddata(x,y,u,X,Y);
V = griddata(x,y,v,X,Y);
figure(1),
pcolor(X,Y,ColorData);
colormap('jet');
figure(2),
pcolor(X,Y,U);
colormap('jet');
figure(3),
pcolor(X,Y,V);
colormap('jet');
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Geographic Plots finden Sie in Help Center und File Exchange

R2022a

### Community Treasure Hunt

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

Start Hunting!

Translated by