Mesh function creates extra face joining first and final data points
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Rashiga Walallawita Walallawita Kankanamge
el 5 de Abr. de 2022
Comentada: Star Strider
el 6 de Abr. de 2022
Hi,
I have data for three variables and I have use mesh function to draw a 3d chart.
I have used the following code,
"
[X,Y]=meshgrid(vx,vz)
Z=griddata(vx,vz,astrain,X,Y)
mesh(X,Y,Z)
"
when I graph the chart, I get an extra face with joining the first and last data point

How can I avoid this?
PS: I'm new to Matlab.
0 comentarios
Respuesta aceptada
Star Strider
el 5 de Abr. de 2022
Try something like this —
vxv = linspace(min(vx), max(vx), numel(vx));
vzv = linspace(min(vz), max(vz), numel(vz));
[X,Y]=meshgrid(vxv,vzv)
Z=griddata(vx,vz,astrain,X,Y)
figure
mesh(X,Y,Z)
grid on
The problem is likely in the original ‘vx’ and ‘vz’ vectors. Creating different version of them to create the interpolation matrices may solve this.
I do not have the necessary data to test this, so I am posting it as UNTESTED CODE.
.
2 comentarios
Rashiga Walallawita Walallawita Kankanamge
el 5 de Abr. de 2022
Editada: Rashiga Walallawita Walallawita Kankanamge
el 5 de Abr. de 2022
Star Strider
el 6 de Abr. de 2022
As always, my pleasure!
Sure!
The original vectors were apparently not monotonically-increasing, causing the problem that your reported.
My code creates a monotonically-increasing vector spanning the range of each original vector (and with the same number of elements, although that is simply for convenience, since the third argument to linspace can be anything reasonable), avoiding the problems of it not being monotonically increasing, that is usually the cause of ‘wrap-around’ problems like those you reported. It then creates appropriate interpolation matrices with the same properties.
Más respuestas (0)
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!