0

I am charting the following data:

a=[...
    0.1,  0.7,   0.00284643369242828;...
    0.1,  0.71,  0.00284643369242828;...]

such that column 1 never surpasses approximately 10 also such that column 2 goes from .7 to 1.

Column 3 seems ok

When i chart my surface using surf(a) it looks like this: enter image description here

it appears not to be properly considering what should be x and y.

anything seem weird there?

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
jason m
  • 6,519
  • 20
  • 69
  • 122

1 Answers1

0

I think you need to try one of two things: either break out your height column into its own rectangular matrix Z and use surf(Z) to plot each point relative to its location in the matrix (so your x- and y-axes will not be scaled the way you want), or you can put your desired x- and y-coordinates in their own vectors, and plot the matrix Z (defined at every point (xi, yj) for all i in N and j in M where x is N elements long and y is M elements long) with surf(x,y,Z).

x = 0.1:0.1:10;    % or whatever increment you need
y = 0.7:0.01:1;    % or whatever increment you need
Z = zeros(length(x),length(y);   % initialized to the correct size, fill with data

I think you are going to have to regenerate your Z-data so that it is in a rectangular matrix that is (elements in x) by (elements in y) in dimension.

EDIT: You do not need to recreate your data. If you know that you have n unique elements in x and m unique elements in y, then you can use:

X = reshape(data(:,1),m,n);
Y = reshape(data(:,2),m,n);
Z = reshape(data(:,3),m,n);
surf(X,Y,Z);

And that should give you what you are looking for.

Engineero
  • 12,340
  • 5
  • 53
  • 75