Help with 3d matrix
1 view (last 30 days)
Show older comments
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 ?
0 Comments
Accepted Answer
Walter Roberson
on 13 Nov 2016
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 Comments
More Answers (0)
See Also
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!