當前位置:編程學習大全網 - 電腦編程 - 怎麽用matlab畫出壹個正方形?

怎麽用matlab畫出壹個正方形?

用matlab畫出壹個正方形方法:畫壹個正方形(meshgrid),旋轉(旋轉矩陣),平移,畫出來。

具體如下:

clear all

clc

r=3;

point=[6 1];

k=sqrt(3);

the=atan(k);

x_or=[0 r];

y_or=x_or;

[x,y]=meshgrid(x_or,y_or);

x_new=cos(the) * x - sin(the) * y;

y_new=sin(the) * x + cos(the) * y;

mesh(x_new,y_new,ones(size(x_new)));

view(0,90);

axis equal;

hold on;

mesh(x_new+point(1),y_new+point(2),ones(size(x_new)));

  • 上一篇:C語言或java編程 計算 1+2+3+...+99+100
  • 下一篇:手機讀卡器怎麽使用?
  • copyright 2024編程學習大全網