0

I'm having trouble generating a three-dimensional surface plot in Scilab. I keep getting the error:

!--error 999 Objplot3d: x vector is not monotonous.

I'm using the command:

plot3d(x,y,z)

where x and y are 200X1 matrices (aka column vectors) and z is a 200X200 matrix. I thought maybe I had to transpose y, but that led to the same error as well.

BadBlock
  • 23
  • 1
  • 7

1 Answers1

0

help plot3d requires, indeed, that the first two arguments be monotonous (ie sorted). I wish someone could tell me why!

Since your x (and possibly y) is not ordered, which causes the error, you just need to sort them, and then pay some attention to keep the z values where they belong. Something like:

[newx,ix]=gsort(x);
[newy,iy]=gsort(y);
newz = z(ix,iy);
plot3d(newx,newy,newz)

(ix is the permutation such that x(ix)==newx)

Leporello
  • 638
  • 4
  • 12