matlab rotate函数怎么用

clf
R=40;E=10;H=50;
J1=pi/2;J2=pi/2;J3=pi/2;J4=pi/2;
hold on
for J=0:pi/720:2*pi
S1=(H/2)*(1-cos(pi*J/J1));
S2=H;
S3=H-(H/2*(1-cos(pi*J/J3)));
S4=0;

if J>(k+2*pi-J4)
S=S4;

elseif J>(2*pi-J4-J3)&J<(2*pi-J4)
S=S3;

elseif J>(2*pi-J4-J3-J2)&J<(2*pi-J4-J3)
S=S2;

else
S=S1;

end
x=E*cos(J)+(sqrt(R*R-E*E)+S)*sin(J);
y=(sqrt(R*R-E*E)+S)*cos(J)-E*sin(J);
plot(x,y);
x1=R*cos(J);
y1=R*sin(J);
plot(x1,y1);
end
hold off
axis equal
怎么让这个图像旋转动起来,好像只能用rotate函数吧求高手

  imrotate是对图像进行旋转操作命令。在matlab命令窗口中键入help imrotate 或 doc imrotate或lookfor imrotate可以获得该函数帮助信息。
  调用格式:
  B = imrotate(A,angle)
  将图像A(图像的数据矩阵)绕图像的中心点旋转angle度, 正数表示逆时针旋转, 负数表示顺时针旋转。返回旋转后的图像矩阵。
  B = imrotate(A,angle,method)
  使用method参数可以改变插值算法,method参数可以为下面这三个值:
  {'nearest'}:最邻近线性插值(Nearest-neighbor interpolation)
  'bilinear': 双线性插值(Bilinear interpolation)
  'bicubic': 双三次插值(或叫做双立方插值)(Bicubic interpolation)
  B = imrotate(A,angle,method,bbox)
  bbox参数用于指定输出图像属性:
  'crop': 通过对旋转后的图像B进行裁剪, 保持旋转后输出图像B的尺寸和输入图像A的尺寸一样。
  {'loose'}: 使输出图像足够大, 以保证源图像旋转后超出图像尺寸范围的像素值没有丢失。 一般上这种格式产生的图像的尺寸都要大于源图像的尺寸。
  程序示例:  
  下面这个程序演示了怎样使用imrotate函数在matlab中产生一个斜矩形。
  img_w = 640;
  img_h = img_w;
  img_oblique_rect = zeros(img_h, img_w);
  % create a oblique(45) rectangle in the matrix
  x1 = int32(img_w / 5 * 2); x2 = int32(img_w / 5 * 3);
  y1 = int32(img_h / 7); y2 = int32(img_h / 7 * 6);
  % 下面这句代码产生一个常规矩形。
  img_oblique_rect(y1:y2, x1:x2) = 1;
  % 利用双线性插值算法对图像进行旋转, 产生一个斜矩形
  img_oblique_rect = imrotate(img_oblique_rect, 45, 'bilinear','crop');
  img_oblique_rect = imcomplement(img_oblique_rect);
  figure('Name', '这是一个斜矩形'), imshow(img_oblique_rect)
    
温馨提示:内容为网友见解,仅供参考
第1个回答  推荐于2017-10-02
R=40;E=10;H=50;k=1;
J1=pi/2;J2=pi/2;J3=pi/2;J4=pi/2;
hold on
for J=0:pi/720:2*pi
S1=(H/2)*(1-cos(pi*J/J1));
S2=H;
S3=H-(H/2*(1-cos(pi*J/J3)));
S4=0;
if J>(k+2*pi-J4);S=S4;
elseif J>(2*pi-J4-J3)&J<(2*pi-J4);S=S3;
elseif J>(2*pi-J4-J3-J2)&J<(2*pi-J4-J3); S=S2;
else S=S1;
end
x=E*cos(J)+(sqrt(R*R-E*E)+S)*sin(J);
y=(sqrt(R*R-E*E)+S)*cos(J)-E*sin(J);
plot(x,y);
comet(x,y)
x1=R*cos(J);
y1=R*sin(J);
plot(x1,y1);
comet(x1,y1)
end
hold off
axis equal本回答被提问者采纳
相似回答