xmin=-2;
xmax=6;
ymin=-2;
ymax=4;
theta=linspace(0,2*pi,200);
x_circle=cos(theta);
y_circle=sin(theta);
theta_slanted_line_array=linspace(0,pi/4,100);
for i=1:length(theta_slanted_line_array)
theta_slanted_line=theta_slanted_line_array(i);
figure(1);clf;hold on;
plot(x_circle,y_circle,'k-','linewidth',2);
plot([xmin,xmax],[0,0],'b','linewidth',2);
plot([-1,xmax],[0,tan(theta_slanted_line)*(xmax+1)],'r','linewidth',2);
plot(2*cos(theta_slanted_line)^2-1,2*cos(theta_slanted_line)*sin(theta_slanted_line),'b','linewidth',2);
axis equal;
axis([xmin,xmax,ymin,ymax]);
grid on;box on;
drawnow;
print('-r200','-dpng',['figure/figure_1_' num2str(i,'fig%05d') '.png']);
end

 Respuesta aceptada

0 votos

你print函数用错了,参考代码:
xmin=-2;
xmax=6;
ymin=-2;
ymax=4;
theta=linspace(0,2*pi,200);
x_circle=cos(theta);
y_circle=sin(theta);
theta_slanted_line_array=linspace(0,pi/4,100);
for i=1:length(theta_slanted_line_array)
   theta_slanted_line=theta_slanted_line_array(i);
   figure(1);clf;hold on;
   plot(x_circle,y_circle,'k-','linewidth',2);
   plot([xmin,xmax],[0,0],'b','linewidth',2);
   plot([-1,xmax],[0,tan(theta_slanted_line)*(xmax+1)],'r','linewidth',2);
    plot(2*cos(theta_slanted_line)^2-1,2*cos(theta_slanted_line)*sin(theta_slanted_line),'b','linewidth',2);
    axis equal;
    axis([xmin,xmax,ymin,ymax]);
    grid on;box on;
    drawnow;
    print(['F:\Matlabwork\figure\',num2str(i,'fig%05d')],'-dpng');
end

Más respuestas (0)

Categorías

Más información sobre MATLAB en Centro de ayuda y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!