add additional parameter to contour plot to generate 3d plot

1 次查看(过去 30 天)
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?

采纳的回答

José-Luis
José-Luis 2013-2-18
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');

更多回答(1 个)

Thorsten
Thorsten 2013-2-18
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')

类别

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