Plotting help
Show older comments
Hi i had a question about plotting for an assignment that i did. My assignment was to find the gas force, gas torque, inertia force, inertia torque, wrist pin force and crank pin force as a function of the crank rotation angle for part A which i did and is correct. For part B i had to plot the acceleration(is the same as xb in my code i just changed it to 30degrees), total torque and the wrist pin force with the lenght varied from 100inch to 5 inch. All the equations in my code should be the correct one. I keep getting the error matrix dimensions must agree for my Wf and i believe it will also give it to me for my Tt.
function[]=Me460hwk3(w)
CR=12; %inch(connecting rod)
Cr=3.5; %inch(crank radius)
Cm=.02; %blob (connecting rod mass)
gl=.4; %(distance to center of gravity as fraction lenght)
Pm=.022; %blob (piston mass)
Pb=3; %piston bore
B=15*(pi/180); %rads
Fgmax=1200; %lb
m4=.022;
m3a=.02*.4;
m3b=.02*.6;
m2a=.3*.06;
mb=m3b+m4;
ma=m2a+m3a;
t=2./(w./60); %seconds time for 2 revolutions
w=w.*(2*pi/60); %rps
t=linspace(0,t,720);
theta1=w.*t;
phi=asin((Cr/CR).*sin(theta1));
%Gas Force's
Fg1=@(t) Fgmax.*sin(((w.*t)./B).*(pi./2)); %for 0 <= theta<= B
Fg2=@(t)(Fgmax./2).*(1+cos((pi.*((w.*t)-B))./(pi-B))); %for B <wt<= pi
Fg3=@(t) 0.*t; %pi<wt<=4pi
Fg=[Fg1(t(1,(1:15))), Fg2(t(1,(16:180))), Fg3(t(1,(181:720)))];
%Gas torque
Tg=(Fg.*Cr).*sin(theta1).*(1+(Cr/CR).*cos(theta1));
%Inertia Force
xb=-Cr*w.^2.*(cos(theta1)+(Cr/CR).*cos(2.*theta1));
Aa=-Cr*w.^2.*cos(theta1)-Cr.*w.^2*sin(theta1);
Fi=(-ma.*Aa-mb.*xb)+(-ma.*Aa);
%Inertia Torque
Ti=(.5.*mb.*Cr.^2*w.^2).*((Cr/2*CR)*sin(theta1)-sin(theta1)-((3.*Cr)/(2.*CR)).*sin(3.*theta1));
%Wrist Pin Force
F34=(Fg+m4.*xb)-(Fg+(m4+m3b).*xb).*tan(phi);
%Crank Pin Force
F32=(m3a.*Cr.*w.^2.*cos(phi)-(m3b+m4).*xb-Fg)+(m3a.*Cr.*w.^2.*sin(phi)+((m3b+m4).*xb+Fg).*tan(phi));
figure(1)
plot(theta1,Fg)
title ('Gas Force')
ylabel('Force')
xlabel('Crank Rotation Angle')
legend ('Gas Force')
axis tight
figure(2)
plot(theta1,Tg)
title ('Gas Torque')
ylabel('Torque')
xlabel('Crank Rotation Angle')
legend ('Gas Torque')
axis tight
figure(3)
plot(theta1,Fi)
title ('Inertia Force')
ylabel('Intertia Force')
xlabel('Crank Rotation Angle')
legend ('Inertia Force')
axis tight
figure(4)
plot(theta1,Ti)
title ('Inertia Torque')
ylabel('Inertia Torque')
xlabel('Crank Rotation Angle')
axis tight
figure(5)
plot(theta1,F34)
title ('Wrist Pin Force')
ylabel('Wrist Pin Force')
xlabel('Crank Rotation Angle')
axis tight
figure(6)
plot(theta1,F32)
title ('Crank Pin Force')
ylabel('Crank Pin Force')
xlabel('Crank Rotation Angle')
axis tight
%Part B
phi2=pi/6;
Cl2=(5:100);
g2=(Cr./Cl2).*cos(phi2);
xb2=(-Cr*w.^2).*(cos(phi2)+(Cr./Cl2).*cos(2.*phi2)); %acceleration
Tt=Tg+Fi+Ti; %total torque
Wf=(Fg+m4.*xb2)-(Fg+(m4+m3b).*xb2).*tan(phi2); %new wrist pin force
figure(7)
plot(g2,xb2)
figure(8)
plot(g2,Tt)
figure(9)
plot(g2,Wf)
1 Comment
Andreas Goser
on 28 Feb 2012
You increase the chances of getting an answer by providing der exact error message ot line you get the error and how you call Me460hwk3.
Answers (0)
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!