Surf plot 2D diffusion FEA

1 回表示 (過去 30 日間)
Jacopo Cossu
Jacopo Cossu 2019 年 5 月 12 日
コメント済み: darova 2019 年 5 月 13 日
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

回答 (1 件)

darova
darova 2019 年 5 月 13 日
Try
h=surf(X,Y,C);
shading interp
set(h,'EdgeColor','k')
  2 件のコメント
Jacopo Cossu
Jacopo Cossu 2019 年 5 月 13 日
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
darova
darova 2019 年 5 月 13 日
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)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by