torque / force problem

5 views (last 30 days)
Allen McCoin
Allen McCoin on 15 Mar 2012
Project for our class. Garage door opening with a electric motor, input for time when child holds on and lets go, also childs weight, plot torque and force with respect to time. I am getting a vertical line in one plot ( barely) and nothing in the other.
I am given a garage door system with equations for force and Torque. The given equations are given in my code. The problem wants me to graph the data, for time going from 0 to 60, and at some time a child with a certain weight jumps on and off, These are inputed in the code, I am having a problem with my graph I feel the code is correct but I am not certain. I have been stariing at it for awhile, Here it is:
function [ ] =Part_B( )
% This function calculates the force that is created from a
% underground garage door opening, then from the force calculation it
% calculates the torque on a motor that is attached to the garage door.
% Both calculations occur between a time period of 0 to 60 seconds.
% During this time period we will also calculate the added force that is
% created when a child hangs onto the door until he lets go
% The output for this data will be represented in a graph
% we are given:
Ld= 16; % this is the length of the door in feet
Wd= 225; % this is the weight of the door in lbs
Ll= 7; % this is the length of the lever arm from motor to door in feet
% we will asssume that the lever arm has negligible weight
% we need to define our inputs and set parameters for them that will be
% within the domain of this system
A= input(' Please enter the weight of the child \n');
% The weight of the child is represented by Wk in the equation
if A<0
error(' The weight of the child must be a positive integer')
end
B= input('What is the time that the child starts to hold onto the door? \n');
if B < 0 || B > 60
error('Please enter a time that is between 0 to 60 seconds')
end
C=input('What time does the child let go of the door? \n');
if C < 0 || C > 60
error('Please enter a time that is between 0 to 60 seconds')
end
if C < B
error('The value needs to be greater than the starting time for child')
end
% For efficiency we need to initialize the values for Force, Torque, and
% time; creating arrays for these will help in plotting and calculation
F = zeros([1,60]); % variable assigned for Force
t= zeros ([1,60]); % variable assigned for time
T= zeros([1,60]); % variable assigned for Torque
% with everything defined we begin the for loop to proceed with the
% calculation
for t=1:60
O = (3*t); % This value is for the angle we are told that the
% for every second the angle increases by 3 degrees, we need this to be
% in Radians in order to make the correct calculations.
if t< B && t > C % this calculates the force when the child is not holding on
F(t)= ((Wd*(Ld/2))* (cos((pi/180)* (O/2)))^2)/(Ll*(1+cos((pi/180)*O)))
else % this is for when the child is holding onto the door
F(t)= ((Wd*(Ld/2)+(A*Ld)) * (cos((pi/180) * (O/2)))^2)/(Ll*(1+cos((pi/180)*O)))
% we now calculate the Torque on the system
T(t) = F(t) * Ll * sin(pi/180*(90 - O/2))
end
end
% top subplot
subplot(2,1,1);
plot(t,F);
% bottom subplot
subplot(2,1,2);
plot(t,T);
end
  2 Comments
Allen McCoin
Allen McCoin on 15 Mar 2012
I am sorry but apparently my code did not copy into the post correctly, it went in as stanndard text above, again I am sorry, Thank you for your patience.
Walter Roberson
Walter Roberson on 15 Mar 2012
I formatted it for you.

Sign in to comment.

Answers (1)

Geoff
Geoff on 16 Mar 2012
Yep you have a couple of errors.
First, you set your time variable t as an array of zeros. You do this above your loop, which also uses the variable t. That overwrites your array, so the final value of t is the last value of the loop.
I removed this line (because it's not even used in the loop):
t= zeros ([1,60]); % variable assigned for time
And put the following line just after your loop:
t = 1:60;
Secondly, this line doesn't look right:
if t< B && t > C % this calculates the force when the child is not holding on
It should be this:
if t < B || t > C
Finally, I recommend you put semi-colons at the end of your force and torque calculations to avoid them being constantly displayed during iteration.
-g-

Categories

Find more on Graphics Performance 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!