Help with 3d matrix

조회 수: 1 (최근 30일)
Ale
Ale 2016년 11월 13일
답변: Walter Roberson 2016년 11월 13일
Hi, I'm learning to use matlab, and I have a problem, I've been trying to do a matrix 3d with the next sizes: X and Y which are 76x88, and and Z is 24x1. And I did:
[x,y]=meshgrid(X,Y);
[x,y,z]=griddata(X,Y,Z,x,y)
But.... x and y returns like 6688x6688, and the griddata gives me a error in the sizes from de matrices... what can I do ?

채택된 답변

Walter Roberson
Walter Roberson 2016년 11월 13일
You are using the griddata form matching https://www.mathworks.com/help/matlab/ref/griddata.html
vq = griddata(x,y,v,xq,yq)
For that syntax, x, y, and v need to be vectors.
Your equivalent to v, Z in your code, is a vector of length 24 x 1, which is fine in itself.
Your x and y start out at 76 x 88 . Neither of those are vectors. They also are not multiples of length 24 (your Z). Your x and y need to be the same length as your z.
Now, if you had an x which was 76 x 88, and a y which was 76 x 88, and a z the same size, then you could
griddata(x(:), y(:), z(:), xq, yq)
for some xq, yq
Your variables give the impression that you have data for a single X/Y plane, and you have a vector of Z values that you want to make predictions at. That is not going to work: you (x, y, z) triples as input to make predictions against.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by