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

2 ビュー (過去 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 Center および File ExchangeContour Plots についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by