How to draw a surface without some of the points?

11 views (last 30 days)
Hello everyone.
I have a data, say,
x=1:1:5
And a have an y data
y=1:1:5
which exists for a limited values of x only. For example, grid of x will be
1 2 3 4 5
1 2 3 4 5
x = 1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
But grid of y then will be
1 1 1 1 1
2 2 2 2
y = 3 3 3
4 4
5
So z(x,y) will not exist for some points in 3D dimension. Surf, as far as I know, can not handle this. It plots all length(x)*length(y) points. How can I draw this surface? Thank you.

Accepted Answer

Jan
Jan on 12 Nov 2012
This is not only a problem of surf(), but even Matlab cannot handle something like this:
1 1 1 1 1
2 2 2 2
y = 3 3 3
4 4
5
A matrix must be rectangular. Try this:
y = [1 1 1 1 1; ...
NaN 2 2 2 2; ...
NaN NaN 3 3 3; ...
NaN NaN NaN 4 4; ...
NaN NaN NaN NaN 5];

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!