1
votes

I would like to plot some disks on a surface plot with Matlab, on the same figure. My problem is to compute a wave scattered by small circular obstacles (disks). The wave is computed on a meshgrid (X,Y), and is stored as a matrix U. It can be plot using the following command: surf(X, Y, U, 'EdgeColor','None', 'facecolor', 'interp'); This leads to a nice picture like this (I can't upload image on stackoverflow)

Now, I want to add the disks on the same picture. Note that "O" is the matrix of the center of the disks, and "a" is the vector of the radii of the disks, and N_scat is the number of disks.

hold on
surf(X,Y, U, 'EdgeColor','None', 'facecolor', 'interp');
theta = [1:361]*2*pi/360;
nb = length(theta);
for p = 1:N_scat
    plot(O(1,p).*ones(1,nb) + a(p).*cos(theta), O(2,p).*ones(1,nb) + a(p).*sin(theta), 'k', 'LineWidth', 1)
end
hold off
view(2);
colorbar;

However, this partly gives the desired results (picture here). Indeed, the disks are displayed, but as you can see, most of them are only partly drawn...

Does someone have an idea ?

The same result happens for : - mesh instead of surf - no option in surf (classical flat representation and edge colored) - Stronger or smaller line width for the disks

Thank you in advance and have a great day !


1

1 Answers

2
votes

The problem is because the circles are drawn at z=0 so they are under surface at some points

You can specify the zdata of the lines in the call to plot, I suggest plotting all the circles at the maximum height of the surface (any higher may affect the colourmap)

Outside the loop define the zdata e.g.

myzdata=max(U(:))*ones(1,nb);

then inside the loop set this to be the zdata of the line

for p = 1:N_scat
    plot(... what you had before ...,'zdata',myzdata)
end