Making circular shapes using equation of circle
Mostra commenti meno recenti
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?
Risposta accettata
Più risposte (1)
Image Analyst
il 5 Apr 2022
0 voti
I think using the viscircles() function would be much simpler. Would that work for you?
1 Commento
Chris Dan
il 6 Apr 2022
Categorie
Scopri di più su 2-D and 3-D Plots in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!