Array incompatible issue in for loop for plotting the small circles
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Jan
le 9 Avr 2022
What is your question? Which problem do you observe? Please post the complete error message.
Réponse acceptée
Voss
le 9 Avr 2022
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Elementary Polygons dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!