Info

This question is closed. Reopen it to edit or answer.

X and Y co-ordinates of a surface?

1 view (last 30 days)
ARUN KUMAR M
ARUN KUMAR M on 21 Jul 2015
Closed: MATLAB Answer Bot on 20 Aug 2021
hi all, i have a surface z=f(x,y).......may i obtain values of x and y if z is known?.....is there any tool for that

Answers (1)

Mike Garrity
Mike Garrity on 21 Jul 2015
Depending on the details of your surface, it can be simple, but for the general case, you're probably looking for contour . It takes the same arguments as surface, but gives you a curve which is passes through all of the X,Y positions with a specified Z.
For example:
[x,y,z] = peaks;
C = contour(x,y,z,'LevelList',0);
If you don't want to draw the results, you can use contourc instead of contour.
The format of the returned matrix C is explained here . It's a bit complicated, because there might be several loops of locations with the same Z. The example above returns something like this:
If you look at C, you'll see that the first column is:
>> c(:,1)
ans =
0
70
The 0 in the first row is the Z level, and the 70 in the second row says that there are 70 X,Y pairs in this loop. That means that c(:,2) through c(:71) are the coordinates of the first loop.
Then if we skip ahead to c(:72), we find:
>> c(:,72)
ans =
0
68
That means that c(:,73) through c(:,140) are the coordinates of the second loop. Finally, if we look at c(:,141), we find:
>> c(:,141)
ans =
0
9
which means that c(:,142) through c(:,150) contain the coordinates of the last loop, which is that tiny one in the center of the picture.
Does that make sense?

Tags

Community Treasure Hunt

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

Start Hunting!