clc
clear
th=pi/10
for i=1:100
th=i*th
if mod(i,2)==0
r=1
else
r=0
end
polarplot(th,r)
hold on
end
matlab小白,想做一个极坐标的中心向四周线条发散的图,思路是使用for循环,偶数r为1,奇数r为0,类似下面这样的图,但我这个代码运行后图像里什么都没有,有大佬能帮忙看一看吗?。

 채택된 답변

0 개 추천

这种可以不用循环体,直接用向量来处理。
更多的代码可参考
clc; clear all; close all;
th=[1:100]*pi/10;
r=repmat([0 1], 1, 50);
polarplot(th,r);

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 启动和关闭에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!