豆粑粑,matab 我画你个饼 ,3D等值面
本帖最后由 meatball1982 于 2018-1-16 14:04 编辑之前,陌生女人的提问,
解答过程中觉得思路还不错(当时是在车上,临时的一个小程序。
今天,突然想到可以用patch的方法画各个3D的等值面。
效果,还不错。
clear all
clc
clf
%% outline
% plot BING
% contact meatball1982@163.com
% if u really, really got problem with this m file.
%% main
% generate data
=peaks(100);
% get the contour line
=contour(x,y,z,18);
% get the structure, close the contour
S=contourdata(C);
clf
%% plot BING
for i = 1: length(S)
s_lev(i,1)=S(i).level;
end
tm_s = unique(s_lev);
n_col = length(tm_s);
=ismember(s_lev,tm_s); % get the lin color position in col_mm
col_mm=jet(n_col);
%% outplut
% the normal one
subplot(1,2,1)
surf(x,y,z,'edgecolor','none')
colormap(col_mm)
view(-20,20)
axis tight
colorbar
% grace BING plot
subplot(1,2,2)
hold on
for i = 1:length(S)
x_lin = S(i).xdata;
y_lin = S(i).ydata;
z_va= S(i).level;
z_lin = z_va.*ones(size(x_lin));
alp_va = abs(z_va./max(abs(z(:))))/2+0.5;
% h=patch(x_lin,y_lin,z_lin,col_mm(locb(i),:),...
% 'edgecolor',col_mm(locb(i),:)); % no transpancy
h=patch(x_lin,y_lin,z_lin,col_mm(locb(i),:),...
'edgecolor',col_mm(locb(i),:),...
'facealpha',alp_va); % transpancy
end
axis tight
view(-20,20)
grid on
页:
[1]