필터 지우기
필터 지우기

Array incompatible issue in for loop for plotting the small circles

조회 수: 3 (최근 30일)
Rohan Shinde
Rohan Shinde 2022년 4월 9일
답변: Voss 2022년 4월 9일
clear all
N=2
Lx=10
Ly=50
R=30
n=48
smallrad=3
meanG1x=75;
meanG1y=30000;
stddevG1x=Lx/0.6745;
stddevG1y=Ly/0.674;
for i=1:N
center1x=normrnd(meanG1x,stddevG1x,i,1);
center1y=normrnd(meanG1y,stddevG1y,i,1);
center1 = [center1x,center1y]; % circle centers
radius1 = repmat(R, i, 1); % circle radii
%for small circles
r1 = R*(rand(n,i));
t1= 2*pi*rand(n,i);
x1 = center1x + r1.*cos(t1);
y1 = center1y + r1.*sin(t1);
center1n=[x1,y1];
radius1n=repmat(smallrad,n,1);
for Circle1 = size(center1, 1):-1:1
% Approximate each circle with a 1000-sided polyshape
C1(Circle1) = nsidedpoly(1e3, ...
'Center', center1(Circle1, :), ...
'Radius', radius1(Circle1));
end
for Circle1n = size(center1n, 1):-1:1
% Approximate each circle with a 1000-sided polyshape
C1n(Circle1n) = nsidedpoly(1e3, ...
'Center', center1n(Circle1n, :), ...
'Radius', radius1n(Circle1n));
end
end
plot(C1)
hold on
plot(C1n)
hold off
  댓글 수: 1
Jan
Jan 2022년 4월 9일
What is your question? Which problem do you observe? Please post the complete error message.

댓글을 달려면 로그인하십시오.

채택된 답변

Voss
Voss 2022년 4월 9일
Without knowing the intent of the code, it's hard to say how to fix it, but here's an attempt:
clear all
N=2;
Lx=10;
Ly=50;
R=30;
n=48;
smallrad=3;
meanG1x=75;
meanG1y=30000;
stddevG1x=Lx/0.6745;
stddevG1y=Ly/0.674;
for i=1:N
center1x=normrnd(meanG1x,stddevG1x,i,1);
center1y=normrnd(meanG1y,stddevG1y,i,1);
center1 = [center1x,center1y]; % circle centers
radius1 = repmat(R, i, 1); % circle radii
%for small circles
r1 = R*rand(n,i);
t1 = 2*pi*rand(n,i);
x1 = center1x.' + r1.*cos(t1);
y1 = center1y.' + r1.*sin(t1);
% center1n=[x1,y1];
% radius1n=repmat(smallrad,n,1);
center1n=[x1(:),y1(:)];
radius1n=repmat(smallrad,n*i,1);
for Circle1 = size(center1, 1):-1:1
% Approximate each circle with a 1000-sided polyshape
C1(Circle1) = nsidedpoly(1e3, ...
'Center', center1(Circle1, :), ...
'Radius', radius1(Circle1));
end
for Circle1n = size(center1n, 1):-1:1
% Approximate each circle with a 1000-sided polyshape
C1n(Circle1n) = nsidedpoly(1e3, ...
'Center', center1n(Circle1n, :), ...
'Radius', radius1n(Circle1n));
end
end
plot(C1)
hold on
plot(C1n)
hold off
axis equal

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Elementary Polygons에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by