필터 지우기
필터 지우기

extract column from 3D meshgrid and griddata matrices

조회 수: 2 (최근 30일)
Antonella Longo
Antonella Longo 2023년 10월 4일
답변: Antonella Longo 2023년 10월 4일
Hello,
I have a 3D meshgrid and griddata interpolation like this:
x = 0;
y = 0;
z = min(zp):dz:max(zp);
[X,Y,Z] = meshgrid(x,y,z);
u_int = griddata(xp,yp,zp,u,X,Y,Z);
Then I need to plot u_int with respect to Z:
plot(Z,u_int)
but the code gets the error:
Error using plot
Data cannot have more than 2 dimensions.
In fact Z and u_int are 3D matrices.
size(Z)
gives
ans =
1 1 201
When I try to extract the third colum with:
ZZ = (1,1,:)
I still get a 3D matrix.
How can I transform this 3D matrix into a vector extracting the thid dimension?

채택된 답변

Walter Roberson
Walter Roberson 2023년 10월 4일
See squeeze
But more likely you would just use
plot(Z(:), u_int(:))
for this very odd case where your x and y are scalars.

추가 답변 (1개)

Antonella Longo
Antonella Longo 2023년 10월 4일
Sorry, I found the answer.
The reshape function has to be used.

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by