The question is:
First part. Create a function drawMUC.m that draws the circular path of a particle knowing its angular velocity ω and the radius of rotation r. Recall the meaning of the period of a circular motion. The Cartesian equations are: x=rcos(ωt) and y=rsin(ωt)
Second part. Once done, add the velocity vector to the trajectory at each point with the quiver command, using the velocity equations: v_x=-rωsen(ωt) and x_y=rωcos(ωt).
Attempt. So this is my code for the first part and then the attempt to the second one
function dibujaMUC(w,r)
t=1:(2*pi)/(w);
y=r.*sin(w.*t);
x=r.*cos(w*t);
plot(x,y)
>>dibujaMUC(0.1,2)
And adding for the second part:
function dibujaMUC(w,r)
t=1:(2*pi)/(w);
y=r.*sin(w.*t);
x=r.*cos(w*t);
plot(x,y)
hold on
vx=-r.*w.*sin(w.*t);
vy=r.*w.*cos(w.*t);
quiver(vx,vy)
>> dibujaMUC(0.1,2)
But then I get this, which I don't think it's exactly what needed:
Description of what plot I get after plugging the second part
Issue where the circle doesn't fully close, zoomed in image of the suggested plot in the posts
CodePudding user response:
Normally I would expect t to start at 0, not 1. Also, you need to tell quiver to attach the direction arrows to the points using a different syntax. E.g.,
t=0:(2*pi)/(w);
:
quiver(x,y,vx,vy)
That being said, the plot would probably look more meaningful if you only attached the direction arrows to a subset of the points or to points that are spaced out more. E.g., this doesn't meet the instructions you were given because you are not plotting the quiver "at each point," but it certainly makes a more readable plot:
n = 5;
quiver(x(1:n:end),y(1:n:end),vx(1:n:end),vy(1:n:end))