
How to create a surface plot from three variables?
12 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Stephen23
on 4 Oct 2018
Edited: Stephen23
on 4 Oct 2018
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 Comments
Stephen23
on 4 Oct 2018
- You create three vectors (X, Y, Z) of the same size.
- 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)

See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!