Making circular shapes using equation of circle
Ältere Kommentare anzeigen
Hello,
I am trying to make circular shapes using this code, but it is plotting half circles or quater circles instead.
close all; clear all;
%% Data for Agglomerates
N = 2; % number of circles
a = 1; % lowest diameter of circles
b = 5 ; % highest diameter of circles
Diam = a + (b-a).*rand(N,1);
Diam = round(Diam);
aaa= 0; % minimum x and y coordyinate limit for circles
bbb= sum(Diam); % maximum x and y coordinat limit for circles
M=2 ;
Axes= zeros(N,M);
Axes(:,1)=aaa+(bbb-aaa)*rand(N,1);
for k=2:M
aaa=randperm(N);
Axes(:,k)=Axes(aaa,1);
end
Axes_Label ={'X axis','Y axis'};
Data_agglo = [Diam Axes];
Data_Label ={'Diameter','X axis','Y axis'};
R = Diam ./2;
%% generate mesh
xmin = min(Data_agglo(:,2)-R);
xmax = max(Data_agglo(:,2)+R);
ymin = min(Data_agglo(:,3)-R);
ymax = max(Data_agglo(:,3)+R);
[Xgrid,Ygrid]= meshgrid(linspace(xmin,xmax,200), linspace(ymin,ymax,200));
plot(Xgrid,Ygrid,'k',Ygrid,Xgrid,'k')
hold all
%% get active dipoles
for i =1:1:size(Data_agglo,1)
active = Xgrid.^2 + Ygrid.^2 <= R(i).^2;
hold on
plot(Data_agglo(i,2)+Xgrid(active),Data_agglo(i,3)+Ygrid(active),'o');
% plot(Xgrid(active),Ygrid(active),'o','MarkerFaceColor','red');
hold on
end
the problem is with the active line or with the whole algorithm.Does anyone knows?
Akzeptierte Antwort
Weitere Antworten (1)
Image Analyst
am 5 Apr. 2022
0 Stimmen
I think using the viscircles() function would be much simpler. Would that work for you?
1 Kommentar
Chris Dan
am 6 Apr. 2022
Kategorien
Mehr zu 2-D and 3-D Plots finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!