MATLAB Answers

Info

This question is closed.

Two codes becoming one

1 view (last 30 days)
DARLINGTON ETAJE
DARLINGTON ETAJE on 13 Aug 2019
Closed: Rik on 13 Aug 2019
Hello Family,
Please I need to create three circles. Challenge One: Circle 1 is small and going round on the circumference of circle 2. Challenge 2: Circle 2 is nearly as big as circle 3. Circle 2 is the inner circle with close diameter with circle 3. Circle 2 is going round inside circle 3. I have the codes for challenge One and challenge Two individually...the problem is to make the two codes work as one.
Challenge One Codes:
r=18;
R=20;
radius=[r R]
velocity=[45 0]
colors=['c','r'] % This is to just make the points different colors
p=zeros(2,1); %here we will store the handles to delete the point
hold on
for i=1:2 %Loop to create multiple circles
th=0:pi/50:2*pi;
xunit=radius(i)*cos(th);
yunit=radius(i)*sin(th);
h=plot(xunit,yunit);
p(i)=plot(xunit(1),yunit(1),'o','MarkerFaceColor',colors(i),'Color',colors(i));
%creates a point on each graph
end
time=[0:0.001:100]; %time vector in seconds
for t=1:length(time)
for i=1:2 %Loop to create multiple circles
delete(p(i)); %delete the old point
%computes the new angle for each point as velocity*time
xunit=radius(i)*cos(velocity(i)*time(t));
yunit=radius(i)*sin(velocity(i)*time(t));
%creates a point on each graph
p(i)=plot(xunit(1),yunit(1),'o','MarkerFaceColor',colors(i),'Color',colors(i));
end
pause(0.01); %wait 0.01 seconds so the plot is displayed
end
hold off
Challenge Two Codes
t = linspace(0,5*pi );
x = cos(t );
y = sin(t );
plot(7*x,7*y)
axis equal
hold on
for t0 = t
h = plot(2*sin(t0),2*cos(t0),'or ','markersize',175);
pause(0.09 )
delete(h )
axis equal
end

  2 Comments

Rik
Rik on 13 Aug 2019
@DARLINGTON: it doesn't motivate people to help you if you respond with a flag instead of a comment. Also, your tone seems quite aggressive. It is on you to make clear what the essence of your question is. Most people on this forum prefer helping two people that have a clear question instead of spending the same time on one question that isn't as clear.
Because I don't see how this question is different from your previous one, I don't see a reason not to close it. Feel free to re-open and edit your question. When you do, make sure to the tools explained on this page to make your question more readable.

Answers (0)

Sign in to answer this question.


Translated by