How to create a surface plot from three variables?

12 次查看(过去 30 天)
Hi all, need some help here. So I am trying to create a surface plot. The independent variables are "h" (convective constant) and "Tw" (wall temperature). For every "h" and "Tw", I would get a corresponding "T1" (surface temperature 1) and "T2" (surface temperature 2). They are all related by a set of non-linear equations which I have already solved in Matlab using the Newton-Jacobian method. The question is, "h" and "Tw" both have a range of values for which they can take (h goes from 0.01 to 0.5 and Tw goes from 350 to 500, and I would like to examine the corresponding change in "T1" and "T2". How can I make a surface plot of (h, Tw, T1) and (h, Tw, T2)? I am aware of the meshgrid method, but there is no explicit expression for "T1" and "T2" since they must be solved through iteration. Any insight? Thank you! Below is my code for the Newton-Jacobian process which helps me get a solution vector x (x(1), x(2)) which contains both of my desire T1 and T2.
sigma = 1.355*10^(-12); %cal/(sec*cm^2*K^4)
epsilon = 0.9;
Tf = 2100; %K
k = 0.1; %cal/(sec*cm*K)
deltaR = 1; %cm
x = [260;
250]; %initial guess
f = zeros (2,1);
iter = 0;
maxIter = 100;
tol = 0.0001;
dx = zeros(2,1);
for h = 0.01:0.01:0.5
for Tw = 350:1:500
while (iter < maxIter)
fprintf('Iteration number: %i\n', iter);
fprintf('x = f =\n');
fprintf('%5.4f %5.4f\n', [x, f]');
f = [epsilon*sigma*(Tf^4-x(1)^4)-(k/deltaR)*(x(1)-x(2));
(k/deltaR)*(x(1)-x(2)) - h*(x(2) - Tw)];
J = [epsilon*sigma*4*(-x(1)^3) - (k/deltaR), (k/deltaR);
(k/deltaR), -(k/deltaR) - h];
dx = -inv(J) * f;
x = x + dx;
iter = iter + 1;
if norm(f,inf) < tol
break;
end
end
end
end

回答(1 个)

Stephen23
Stephen23 2018-10-4
编辑:Stephen23 2018-10-4
If you cannot use meshgrid and do not have gridded data, then the easiest solution is to create three vectors (X, Y, Z), create a Delaunay triangulation, and plot that:
For example, taken from my answer in that thread:
  2 个评论
Duc Hoang
Duc Hoang 2018-10-4
Thanks for the quick response. I am not sure if i am able to follow the method presented in the guide you provided. Would you please help me clarify and elaborate on how should I approach this problem?
Stephen23
Stephen23 2018-10-4
  1. You create three vectors (X, Y, Z) of the same size.
  2. Use the code in the link I showed. It is only one line:
trisurf(delaunay(X,Y),X,Y,Z)
You can easily try it with a small example:
>> X = randi(9,1,15);
>> Y = randi(9,1,15);
>> Z = randi(9,1,15);
>> trisurf(delaunay(X,Y),X,Y,Z)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by