Plotting circles in a for loop using a time step

조회 수: 13 (최근 30일)
Hannah Haynie
Hannah Haynie 2019년 9월 16일
댓글: Hannah Haynie 2019년 9월 23일
Hi there,
I am looking for enlightenment and I am not even sure if this will make sense, but I am trying to plot some cells to help me with reducing costs in a Biology lab. I would like to create a Matlab for loop that plots circles with origin on the circumference of the original plotted circle this will happen at each timestep. This is to mimic cell division.
My original code is:
clear all
close all
clc
for k = 1:5 %numberofruns
x0=2;
y0=1;
r=1;
theta=-pi:0.01:pi;
x=r*cos(theta)+x0;
y=r*sin(theta)+y0;
plot(x,y)
hold on
scatter(x0,y0,'or')
% axis square
% ----------------------------------------
% divide your circle to n sectors
n=2
tet=linspace(-pi,pi,n+1)
xi=r*cos(tet)+x0
yi=r*sin(tet)+y0
plot(xi,yi)
x0=1;
y0=1;
r=1;
theta=-pi:0.01:pi;
x=r*cos(theta)+x0;
y=r*sin(theta)+y0;
plot(x,y)
hold on
scatter(x0,y0,'or')
% axis square
% ----------------------------------------
% divide your circle to n sectors
n=2
tet=linspace(-pi,pi,n+1)
xi=r*cos(tet)+x0
yi=r*sin(tet)+y0
plot(xi,yi)
% for k=1:numel(xi)
% plot([x0 xi(k)],[y0 yi(k)])
% hold on
% end
x0=3;
y0=1;
r=1;
theta=-pi:0.01:pi;
x=r*cos(theta)+x0;
y=r*sin(theta)+y0;
plot(x,y)
hold on
scatter(x0,y0,'or')
% axis square
% ----------------------------------------
% divide your circle to n sectors
n=2
tet=linspace(-pi,pi,n+1)
xi=r*cos(tet)+x0
yi=r*sin(tet)+y0
plot(xi,yi)
pause(1) %timeinsec
shg
end
Thanks in advance!

채택된 답변

the cyclist
the cyclist 2019년 9월 16일
Your code runs fine for me, and creates a figure. What's the problem? What's your question?
I'm going to take a stab at an answer, though. The default axes will mean your mathematical circles will not look like circles. Try
axis equal
to fix that.
  댓글 수: 1
Hannah Haynie
Hannah Haynie 2019년 9월 23일
Hi Cyclist,
Thank you for your answer! My coding here is a work in progress, but that was a helpful suggestion.
Have a nice day.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by