|
I ever met a similar problem. And my OS is Windows7, there is something wrong with OpenGL Renderer. If you also use Windows7 or Vista, I think you can try this: set(gcf, 'Renderer', 'painters')
Put it under the figure code, it may fix the problem. Good luck!
"Koos" wrote in message <jrfseq$3jf$1@newscl01ah.mathworks.com>...
> Hello,
>
> I'm trying to simulatie a bobsled on a track. In this case the track is a looping.
> Everything works and the plots are beautiful, but when I try to make a video of the plots, it fails. Matlab is making a video, but in the video you only see the first frame and you also see the Matlab editor slightly through it.
>
> So my question is:
> What causes the error that the video only takes the first frame, while matlab does the whole simulation (about 75 frames)?
>
> My matlab code is:
> %% Figure 1
> nFrames = numel(x(:,1));
> mov(1:nFrames) = struct('cdata', [],...
> 'colormap', []);
> DELAY = 0.01;
> figure('units','normalized','outerposition',[0 0 1 1]);
> figure(1);
> axis tight
> set(gca,'nextplot','replacechildren');
> for i = 1:numel(x(:,1))
> clf;
> x_coor=-0.75*pi:0.1:1.75*pi;
> y_coor=-pi/3:0.1:pi/3;
> [ff,gg]=meshgrid(x_coor,y_coor);
> x1 = (R+r.*cos(gg)).*cos(ff);
> z1 = (R+r.*cos(gg)).*sin(ff);
> y1 = r.*sin(gg)+k.*ff;
> surf(x1,y1,z1,'EdgeColor','blue','LineStyle',':','FaceLighting','gouraud');
> grid on;
> camlight
> view(-30,15);
> alpha(0.5);
> title('Looping','FontSize',14)
> xlabel('x')
> ylabel('y')
> zlabel('z')
> hold on;
> p = x(i,1);
> q = x(i,2);
> x2 =(R+r.*cos(q)).*cos(p);
> z2 =(R+r.*cos(q)).*sin(p);
> y2 =r.*sin(q)+k.*p;
> plot3(x2,y2,z2,'ro','LineWidth',2);
> mov(i) = getframe(gcf);
> pause(DELAY);
> end
> hold off
> %movie(mov,1)
> movie2avi(mov, 'looping.avi','FPS',10, 'compression','none','quality',100);
>
> Short explanation of the plot:
> At first, I solved a differential equation and the output is stored in the vector x. In the plot, I first plot the track (the looping) with 'surf' and after that the vector x (output of the ODE) with 'plot3' by using 'hold on'.
>
> Thanx in advance!
>
> Koos
|