Surf plot: Data dimensions must agree.

4 views (last 30 days)
Can't for the life of me figure this out..
trying to plot the following:
surf(transect1.lon,transect1.lat,transect1.z,transect1.u)
They have the following dimensions:
size(transect1.lon) = 29 1
size(transect1.lat) = 29 1
size(transect1.z) = 29 30
size(transect1.u) = 29 30

Accepted Answer

Star Strider
Star Strider on 5 Nov 2017
Either ‘transect1.lon’ or ‘transect1.lat’ has to be (30x1), or you have to remove one column from ‘transect1.z’ and ‘transect1.u’ so the dimensions match. (An option is to interpolate the matrices to make them both (29x29), or interpolate one of the vectors to (30x1).)
The surface plots only take one matrix argument, so you have to use hold to plot both in the same axes.
After you make sure the vectors and matrix dimensions match, see if this does what you want:
figure
surf(transect1.lon,transect1.lat,transect1.z)
hold on
surf(transect1.lon,transect1.lat,transect1.u)
hold off
grid on
NOTE I can’t run your code to test this, so this is UNTESTED CODE.

More Answers (0)

Categories

Find more on Graphics Object Programming 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!