Borrar filtros
Borrar filtros

Array incompatible issue in for loop for plotting the small circles

3 visualizaciones (últimos 30 días)
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 comentario
Jan
Jan el 9 de Abr. de 2022
What is your question? Which problem do you observe? Please post the complete error message.

Iniciar sesión para comentar.

Respuesta aceptada

Voss
Voss el 9 de Abr. de 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

Más respuestas (0)

Categorías

Más información sobre Elementary Polygons en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by