當前位置:編程學習大全網 - 編程軟體 - matlab如何畫圓

matlab如何畫圓

使用MATLAB畫圓的方法有兩種,分別如下:

1、啟動MATLAB,新建腳本,輸入以下代碼:

close all; clear all; clc

r=2; theta=0:pi/100:2*pi;

x=r*cos(theta); y=r*sin(theta);

rho=r*sin(theta);

figure(1)

plot(x,y,'-')

hold on; axis equal

fill(x,y,'c')

figure(2)

h=polar(theta,rho);

set(h,'LineWidth',2)

2、保存和運行上述腳本,在figure(1)中得到plot(x,y)和fill(x,y)繪制的圓。

3、使用plot(x,y)畫圓只需要接著輸入以下代碼:

figure(3)

subplot(1,2,1);plot(x,y,'-');hold on; axis square

fill(x,y,'c')

subplot(1,2,2);h=polar(theta,rho);set(h,'LineWidth',2)

4、點擊保存並運行。

  • 上一篇:鹽城日月路小學東校區西校區哪個好
  • 下一篇:2.5如何將尺寸測量數據導入表格?
  • copyright 2024編程學習大全網