Mike on MATLAB Graphics

Graphics & Data Visualization

Note

Mike on MATLAB Graphics has been archived and will not be updated.

Happy New Year

Happy New Year

I hope that you had a great year and that next year is even better for you.

Here's a little bit of fluff to finish out 2014.

n1 = 5;
n2 = 200;
n3 = 500;
ang1 = linspace(0,2*pi,n2);
ang2 = linspace(0,2*pi,n3);
c1 = repmat(cos(ang1),[n1 1]);
s1 = repmat(sin(ang1),[n1 1]);
y = linspace(-1,1,n1)';
h = surf(zeros(2,length(ang1)));
h.EdgeColor = 'none';
h.FaceColor = 'interp';
h.FaceLighting = 'gouraud';
h.CData = repmat(y,[1 n2]);
view(3)
xlim([-2 2])
ylim([-2 2])
zlim([-1 1])
camlight right
axis off
while true
    for o=ang2(1:(end-1))
        t = 3*pi*sin(o)*sin(ang1+o);
        c2 = y*cos(t);
        s2 = y*sin(t);
        h.XData = (1+c2).*c1;
        h.YData = (1+c2).*s1;
        h.ZData = s2;
        drawnow
    end
end

animation




Published with MATLAB® R2014b


  • print