Plotting multiple graphs but only a graph is shown

1 次查看(过去 30 天)
I tried to create circles with different radii in one figure. I have put the data of the radii in an array and try to plot the curves. However, only the circle with largest radius shown. I have checked the array a(i,1) is not zero at all. In case the file 'numberden' is needed, I have attached the file here.
clear
clc
clf
R_MAX=sqrt(3)*2*50;
mr=0.025;
dr=(R_MAX-mr)/1000;
filename = 'numberden0.txt';
A=importdata(filename);
ei=A(:,1);
ej=A(:,2);
i=0;
a=zeros(1000,1);
for i=1:1:1000
if (ei(i)~=0)
a(i,1)=ej(i);
elseif (ei(i)==0)
a(i,1)=0;
end
end
a;
theta=linspace(0,2*pi,1000);
for j=1:1:1000
x=a(i,1)*sin(theta);
y=a(i,1)*cos(theta);
hold on
scatter(x,y,'.')
hold off
end

采纳的回答

KSSV
KSSV 2020-5-15
You must remove hold off in the for loop.
  7 个评论
KSSV
KSSV 2020-5-15
filename = 'numberden0.txt';
A=importdata(filename);
ei=A(:,1);
ej=A(:,2);
a = zeros(size(ei)) ;
a(ei~=0) = ej(ei~=0) ;
theta=linspace(0,2*pi,length(a))';
x = a.*sin(theta) ;
y = a.*cos(theta) ;
plot(x,y,'.r')
Simon219
Simon219 2020-5-15
Thanks, here is what I got for the garph (graph.fig). However I found polarplot maybe a better tool for me since what I want is several circles with different radius. So I have the code:
r=ones(1,360);
hold on
for i=1:1:length(a)
theta=linspace(0,2*pi,length(a));
k=a(i)*r
polarscatter(theta, k)
end
hold off
Error appeared that adding polar plot axes is not supported. What's wrong with that

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by