2D plot of deformation data
Ältere Kommentare anzeigen
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 Kommentare
Mathieu NOE
am 6 Mär. 2023
hello
can you share your data file ?
Sara
am 6 Mär. 2023
William Rose
am 6 Mär. 2023
Bearbeitet: William Rose
am 6 Mär. 2023
[edit: fix typos and change two lines from text to code]
You say "When I used the U and V I got this image", but the code you posted does not use U and V. It uses the c array for color. If you attach array "data" array as a file, others could see. Are the values of c (which are given, not calculated in your code) derived from U and V, or are the c values independent of U and V? If they are independent, and if you are interested in using color to represent the displacements that are in the U and V vectors, then you can ignore the c values.
Since displacement includes both U and V components, you have to decide how you want to combine them for plotting purposes. Two obvious options (among many possible options) are
d=sqrt(U.^2+V.^2);
or
d=max(U,V);
Then you use d to compute the ColorData:
ColorData = griddata(x,y,d,X,Y);
and plot as before.
Sara
am 7 Mär. 2023
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.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Convert Image Type finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


