Surf plot 2D diffusion FEA

Hy,
I'm trying to code a 2D diffusion problem. In the center from -1(mm) to +1(mm) both in x and y direction, the concentration of the solute is 100. The solutes then starts to diffuse in x and y direction with different rate (i.e. the diffusivities in x and y directions are different).
My code is working fine, but when I plot the initial condition (shown in the attached image) using the surf plot, the plot shows the initial condition as yellow color on the grid from -1 to +1.5, but this is misleading. The initial condition is between -1 to 1. I think this is because how the surf plot interprets the matrix and defines the color. You can see in the following images that the Z values on the grid points (the value of concentration) on the top and right hand side of the yellow region is zero.
What I need is to make a plot that shows the initial condition correctly (in this graph only from -1 to +1 colored yellow).
Is there any ways to solve this problem?
I attached the code as well.
Thanks a lot

Answers (1)

Try
h=surf(X,Y,C);
shading interp
set(h,'EdgeColor','k')

2 Comments

Hy,
thanks for your suggestion. I tried it out, but now it shows a gradient coloring along the edge of the yellow box in the center. I would like to have the edge completely blue.
2D-diffusion.jpg
Whaat if modificate original data a little
[row, ~] = find(C==100,1,'last');
[~, col] = find(C==100,1,'first');
C1 = C;
C1(row,:) = 0;
C1(:,col) = 0;
surf(X,Y,C1)

Sign in to comment.

Categories

Find more on Images in Help Center and File Exchange

Asked:

on 12 May 2019

Commented:

on 13 May 2019

Community Treasure Hunt

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

Start Hunting!