フィルターのクリア

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 Center および File ExchangeElementary Polygons についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by