필터 지우기
필터 지우기

How to plot 3D contour in real-time for the shortest time?

조회 수: 1 (최근 30일)
Denis Perotto
Denis Perotto 2019년 2월 12일
I need to plot 3D contour in real-time layer-by-layer. I got it already, that MATLAB does not have a standard function for 3D contour plot ( color = f(x,y,z) ), so I plot my graph dot-by-dot using a 'scatter3' function like this:
X = 10; Y = 20; Z = 50;
c = cell(X,Y,Z);
for i = 1:X
for j = 1:Y
for k = 1:Z
c{i,j,k} = [(i-1)/X (j-1)/Y (k-1)/Z randi(5)];
end
end
end
zcount = 2;
figure
while zcount <= Z
cla;
for k = 1:zcount
for i = 1:X
for j = 1:Y
clr = clrdet(c{i,j,k}(4));
scatter3(c{i,j,k}(1),c{i,j,k}(2),c{i,j,k}(3),...
'MarkerFaceColor',clr,'MarkerEdgeColor',clr);
drawnow;
hold on;
axis equal;
grid on;
end
end
end
zcount = zcount + 1;
end
function res = clrdet(int)
switch int
case 1
res = 'r';
case 2
res = 'g';
case 3
res = 'b';
case 4
res = 'c';
case 5
res = 'm';
otherwise
res = 'k';
end
end
The execution of my code takes a lot of time (about 0.5 sec a layer), when the whole contour should be plot in less than 0.4 seconds. Can you, please, suggest me, how to speed up my code? Maybe there is a way to plot 2D contour (XY section) on 3D graph?

답변 (0개)

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by