0

Im new in matlab programming and I have small issue.

I want to draw a plot 3d of Euclidean distance function for 2 coordinates, like in this picture below:

pic

Could you help me with the source code? How I can draw this plot? My first thoughts was wrong:

[A] = meshgrid(-100:.5:100, -100:.5:100);   
D1 = bwdist(A);
figure
surf(double(A), double(D1)) 
Roger Rowland
  • 25,885
  • 11
  • 72
  • 113
user3146344
  • 207
  • 1
  • 3
  • 16

1 Answers1

1

It is done like this...

[x, y] = meshgrid(-100:.5:100, -100:.5:100);   

The you have to calculated the euclidean distances. I assume you want them with the origin.

z = (x.^2 + y.^2).^0.5;   % square root of sum of squares (euclidean distance with origin)
surf(x, y, z);

NOTE: meshgrid(-100:.5:100, -100:.5:100) might make the resolution of the plot too high. If you have trouble viewing the plot, reduce the resolution.

Use [x, y] = meshgrid(-100:5:100, -100:5:100);

Buddhima Gamlath
  • 2,318
  • 1
  • 16
  • 26