torque / force problem

조회 수: 5 (최근 30일)
Allen McCoin
Allen McCoin 2012년 3월 15일
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
Allen McCoin
Allen McCoin 2012년 3월 15일
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 2012년 3월 15일
I formatted it for you.

댓글을 달려면 로그인하십시오.

답변 (1개)

Geoff
Geoff 2012년 3월 16일
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-

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by