MATLAB Analyzing Falling Object w/ Linear Friction: Troubleshooting Code

AI Thread Summary
The discussion revolves around a physics simulation involving an object falling from rest, factoring in linear friction. The user shares a code snippet intended to calculate the position of the object over time, but encounters an error in the equation used for position calculation. The error arises from the incorrect use of the exponential function. A solution is provided, suggesting the replacement of the original equation with one that correctly implements the exponential function using either "exp" or the element-wise operator ".*" for array calculations. The corrected code successfully computes the position and plots the results, demonstrating the importance of proper syntax in programming for accurate simulations.
Raziel2701
Messages
128
Reaction score
0
It's an object that's falling from rest. The equation takes into account linear friction. in any case, this is is my code or program of whatever it is called:

m=80;%Mass of ignorance
g=9.8;%Gravity
beta=1.6*10^-4;%Given coefficient for air at STP
D=.4;%Diameter of Palin, assuming she's a spherical object
b=beta*D;%Coefficient of linear friction
t=0:.2:60;


x=(m./b)*(g*t + e^(-b*t./m));

plot(t,x)
grid on
xlabel('time','FontSize',16)
ylabel('Position of Sarah Below Helicopter','FontSize',16)

I get this error:
Error in ==> HW13myprogram at 10
x=(m./b)*(g*t + e^(-b*t./m));

What am I doing wrong?
 
Physics news on Phys.org


replace your equation with

x=(m/b)*(g*t + e.^(-b*t/m));
 


It worked fine for me with:

x=(m./b)*(g*t + exp(-b*t./m));
 

Similar threads

Replies
5
Views
2K
Replies
4
Views
2K
Replies
4
Views
1K
Replies
2
Views
8K
Replies
17
Views
2K
Replies
1
Views
4K
Replies
9
Views
3K
Back
Top