I have written the beginnings of a MATLAB script that solves for some values for the following crank and piston system:
So far I have employed a For loop which uses the angle theta as the index. Because of this, I am unable to collect the outputs of my loop and end up only with the final values for each variable. How can I rewrite my for loop using a different index? Thanks in advance!
Here is my script so far:
clc;clear
%set value for w in (rad/s)
w=-418.8790205;
%Set crank radius in (m)
r=0.047;
%create rotational velocity matrix
wc=[0,0,w];
%Set connecting rod radius in (m)
l=0.2254;
%For Loop
for theta=0:pi/18:2*pi
%rAO= location of point A relative to O
rAO=r*[cos(theta),sin(theta),0];
%VA=Velocity of point A
VA=cross(rAO,wc);
%Solve for angle phi
phi=acos(sqrt(1-(r/l)^2*(sin(theta))^2));
%rCA= location of point C relative to A
rCA=l*[cos(-phi),sin(-phi),0]
end
Best Answer