How to create a consolidated 'average' surface of three or more surfaces?

1 次查看(过去 30 天)
I have three surfaces as follows:
Z1 = x + y; Z2 = 2x + y; Z3 = 3x +y;
How can I create a consolidated 'average' graph of all three equations?
Thank you

采纳的回答

arich82
arich82 2014-5-23
It's not entirely clear (to me) what you want, but you can simply take the avg of z and plot it if that's what you want:
%%make data
[X, Y] = meshgrid(-2:0.2:2, -3:0.3:3);
Z(:, :, 1) = X + Y;
Z(:, :, 2) = 2*X + Y;
Z(:, :, 3) = 3*X + Y;
%%compute average
% simple approach:
% Z_avg = (Z1 + Z2 + Z3)/3; % for this example, Z_avg and Z2 are equivalent
% more generally:
Z_avg = mean(Z, 3);
%%plot original data
k = 1;
hf(k) = figure('WindowStyle', 'docked');
ha(k) = axes;
hold(ha(k), 'all');
hs(1) = surf(ha(k), X, Y, Z(:, :, 1));
hs(2) = surf(ha(k), X, Y, Z(:, :, 2));
hs(3) = surf(ha(k), X, Y, Z(:, :, 3));
view(3);
grid(ha(k), 'on');
title(ha(k), 'original planes');
%%plot avg.
k = 2;
hf(k) = figure('WindowStyle', 'docked');
ha(k) = axes;
hs(4) = surf(ha(k), X, Y, Z_avg);
view(3);
grid(ha(k), 'on');
title(ha(k), 'avg. plane');
It seems like you've been asking variations of this question for quite some time; is this what you were looking for? If not, what aspect are you confused about?

更多回答(0 个)

类别

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