shifting cubes along x axis

1 visualización (últimos 30 días)
hsgaya
hsgaya el 29 de Ag. de 2019
Comentada: hsgaya el 30 de Ag. de 2019
% shifting along x axis
for i=0:-65:-500
x14=0+i
x24=40+i;
x34=40+i;
x44=0+i;
x54=0+i;
x64=40+i;
x74=40+i;
x84=0+i;
%y coordinates
y14=0
y24=0;
y34=14;
y44=14;
y54=0;
y64=0;
y74=14;
y84=14;
%z coordnates
z14=0
z24=0;
z34=0;
z44=0;
z54=15;
z64=15;
z74=15;
z84=15;
%First cube
patch([x14 x24 x34 x44],[y14 y24 y34 y44],[z14 z24 z34 z44],'r') % Draw first side of a cube
patch([x14 x24 x64 x54],[y14 y24 y64 y54],[z14 z24 z64 z54],[0.230003 0.370006 0.170003]) % Draw second side of a cube
patch([x54 x64 x74 x84],[ y54 y64 y74 y84],[ z54 z64 z74 z84 ],[0.419599 0.556902 0.137303]) % Draw third side of a cube
patch([x14 x54 x84 x44],[y14 y54 y84 y44],[z14 z54 z84 z44],'y') % Draw fourth side of a cube
patch([x24 x34 x74 x64],[y24 y34 y74 y64],[z24 z34 z74 z64],'o') % Draw fifth side of a cube
patch([x34 x74 x84 x44 ],[y34 y74 y84 y44 ],[z34 z74 z84 z44 ],'black') % Draw sixth side of a cube
i=i+1;
for i2=0:10:100
M1=[x14+i2 y14 z14];
M2=[x24+i2 y24 z24];
M3=[x34+i2 y34 z34];
M4=[x44+i2 y44 z44];
M5=[x54+i2 y54 z54];
M6=[x64+i2 y64 z64];
M7=[x74+i2 y74 z74];
M8=[x84+i2 y84 z84];
x1=M1(1);
x2=M2(1);
x3=M3(1);
x4=M4(1);
x5=M5(1);
x6=M6(1);
x7=M7(1);
x8=M8(1);
y1=M1(2);
y2=M2(2);
y3=M3(2);
y4=M4(2);
y5=M5(2);
y6=M6(2);
y7=M7(2);
y8=M8(2);
z1=M1(3);
z2=M2(3);
z3=M3(3);
z4=M4(3);
z5=M5(3);
z6=M6(3);
z7=M7(3);
z8=M8(3);
%second cube
clf reset % clear the figure
patch([x1 x2 x3 x4],[y1 y2 y3 y4],[z1 z2 z3 z4],'y') % Draw first side of a cube
patch([x1 x2 x6 x5],[y1 y2 y6 y5],[z1 z2 z6 z5],'y') % Draw second side of a cube
patch([x5 x6 x7 x8],[y5 y6 y7 y8],[z5 z6 z7 z8],'r') % Draw third side of a cube
patch([x1 x5 x8 x4],[y1 y5 y8 y4],[z1 z5 z8 z4],'blue') % Draw fourth side of a cube
patch([x2 x3 x7 x6],[y2 y3 y7 y6],[z2 z3 z7 z6],'o') % Draw fifth side of a cube
patch([x3 x7 x8 x4 ],[y3 y7 y8 y4 ],[z3 z7 z8 z4 ],[0.419599 0.556902 0.137303]) % Draw sixth side of a cube
axis on;
axis([-500 500 -200 200 0 105]) % Viewable axis are defined
view(3);
set(gcf , 'Units' , 'Normalized' , 'Outerposition' , [0,0,1,1]);
view(3);
pause(0.00000000000001)
end
i=i+1;
end
Hello,
I'm trying to shift more cubes along x axis at the same time.
But according to my code it generate one cube only.How can I change it? Please help me.
  4 comentarios
darova
darova el 29 de Ag. de 2019
You are clearing all figures and asking why you have only one figure?
hsgaya
hsgaya el 30 de Ag. de 2019
ohhh...really..It's my mistake

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by