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

조회 수: 13 (최근 30일)
A
A 2014년 5월 23일
댓글: A 2014년 5월 24일
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