add additional parameter to contour plot to generate 3d plot

5 views (last 30 days)
I have an equation which has 3 unknown variables V, s, and T. I want to produce a contour plot that shows what happens when each of these variables changes. Currently I can do this by creating a vector for both V and T but keep s as a constant:
V = 1:250;
T = linspace(1,25,length(V));
s = 30;
for j = 1:length(T)
D(j,:) = (3.*V.*(s^2))./(T(j).*((T(j).^2)-...
(3.*T(j).*s)+(3.*(s.^(2)))));
end
Then by plotting D as a contour plot:
pcolor(T,V,D');shading interp
we can see that when V is large and T is small, D will be large. From here, I would like to generate a 3d plot where I can also show the influence of changing 's'. At the moment 's' is a constant, so I can show how s affects the outcome by producing say 4 different figures for 4 different values of s. However, it would be better if I could generate one plot with 3 axis showing how D varies with V, T, and s. Could anyone provide some information about the best way of doing this?

Accepted Answer

José-Luis
José-Luis on 18 Feb 2013
What you are asking is basically how to plot four-dimensional data in a two dimensional plane. It is not easy, and tends to be messy, IMO. They way you do it sounds reasonable to me, but if you really want to have everything in a single plot, you could always use the slice() function:
V = 1:250;
T = linspace(1,25,length(V));
ii = 10:10:40;
all_data = nan(250,250,4);
counter = 1;
for s = ii
for j = 1:length(T)
D(j,:) = (3.*V.*(s^2))./(T(j).*((T(j).^2)-...
(3.*T(j).*s)+(3.*(s.^(2))))); %This could be vectorized
end
all_data(:,:,counter) = D';
counter = counter + 1;
end
[x y z] = meshgrid(V,T,ii);
sH = slice(x,y,z,all_data,[],[],ii);
set(sH,'EdgeColor','none');

More Answers (1)

Thorsten
Thorsten on 18 Feb 2013
You can use scatter3 and experiment with the size and the color of the dots
scatter3(X(:), Y(:), Z(:), 100*map01(V(:))+0.1, 255*(map01(V(:))), 'filled')

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by