From: Nicki Chemerys on
Hello to everyone! Help, please, that's such a problem here. The resulting paraboloids must be animating in one window, while the frequency of contractions of each depends only on it's parameters and wasn't linked to another.I tried to use nested loops but it works strange.

Code:

a=5;
b=a;
c=10;

u = (0:0.05*pi:2*pi)';
v = [0:0.05*pi:2*pi];


d=1/2;
e=2^d;
a2=a/e;
b2=a/e;
c2=c;
h=1/3;
%hS1=surf(X,Y,Z);
%hS2=surf(X2,Y2,Z2);
axis([-20 20 -20 20 -10 10]);
set(gca,'nextplot','replacechildren');

for n=1:10
for i=1:4
k1=(sin(pi*i/4)+0.5)^h;
a=a*k1;
c=c*k1;
X = a*sin(u)*cos(v);
Y = a*sin(u)*sin(v);
Z = c*cos(u)*ones(size(v));
Z(find(Z>0))=0;
end
for j=1:8
k2=(sin(pi*j/8)+0.5)^h;
a2=a2*k1;
b2=a2*k1;
c2=c2*k1;
X2 = a2*sin(u)*cos(v)%+4;
Y2 = b2*sin(u)*sin(v);
Z2 = c2*cos(u)*ones(size(v));%+0.25;
Z2(find(Z2>0))=0;
%X2(find(X2>a*k1))=a*k1;
%Y2(find(Y2>a*k1))=a*k1;
end

hS1=mesh(X,Y,Z);
alpha(.11)
hold on
hS2=surf(X2,Y2,Z2);
hold off

axis([-20 20 -20 20 -20 10]);
F(n) = getframe;
end

movie(F,10)