フィルターのクリア

Am I doing this right?

4 ビュー (過去 30 日間)
Jacob Savona
Jacob Savona 2015 年 2 月 23 日
編集済み: Rick Rosson 2015 年 2 月 23 日
You are driving a car along a straight road for t = 50s. Assume that friction is negligible but drag is not, where F .5b(v_n-1)^2 , b is a given constant, and v_n-1 is the velocity at the previous time step. For the duration of the trip as described below, calculate the position, velocity, and netacceleration of the car. Use one or more for loops to simulate the behavior of the car starting at t = 0 until t = 50s, with Δ t = 0.5s. Mass of car and you=1428.8kg and b= 1.04 N*s2/m2.
a. Starting from rest, where initial position of x(0) = 0 and v(0) = 0, you apply an initial, constant acceleration of a = 3m/s , until you reach 65 mph(29.05m/s). Upon reaching 65 mph, you maintain a constant velocity.
Here's My code:
m=1428.8;
x=0;
a=3;
for t=[0:.5:50]
v_n=a.*t;
F_drag=.5*(1.04)*v_n;
F=m*a
F_net=F-(F_drag);
if F_net==0
v_n;
p=v_n/a;
end
end
  1 件のコメント
Jacob Savona
Jacob Savona 2015 年 2 月 23 日
Fdrag = .5b(v_n-1)^2 for any confusion

サインインしてコメントする。

回答 (2 件)

Rick Rosson
Rick Rosson 2015 年 2 月 23 日
編集済み: Rick Rosson 2015 年 2 月 23 日
% Mass of the vehicle (in kilograms):
m = 1428.8;
% Applied acceleration (in m/s^2):
a_gas = 3;
Time increment (in seconds):
dt = 0.5;
% Time vector (in seconds):
t = (0:dt:50)';
% Number of data samples:
N = length(t);
% Pre-allocate state variables:
x = nan(N,1);
v = nan(N,1);
a = nan(N,1);
% Initial conditions:
x(1) = 0;
v(1) = 0;
a(1) = a_gas;
% Main simulation update loop:
for n = 2:N
...
...
a(n) = ...
v(n) = v(n-1) + ...
x(n) = x(n-1) + ...
...
...
end
  6 件のコメント
Rick Rosson
Rick Rosson 2015 年 2 月 23 日
編集済み: Rick Rosson 2015 年 2 月 23 日
I don't understand - you already know how to calculate the drag, you included the calculation in the code that you posted as part of your question.
You have everything you need to solve this problem. Try something in MATLAB, check to see if it works, and if it does not, then try to figure out how to fix it. If you want to learn physics and/or MATLAB, you have to put in some effort. No one is going to do it for you.
Best of luck.
Rick Rosson
Rick Rosson 2015 年 2 月 23 日
BTW, the drag is NOT a function of time. It's a function of velocity. So if you first calculate the velocity v at time step n, then you can calculate the drag. Once you know the drag, you can calculate the net force. And then the acceleration....

サインインしてコメントする。


Image Analyst
Image Analyst 2015 年 2 月 23 日
Have you looked at my answer in your earlier posting of this question? http://www.mathworks.com/matlabcentral/answers/179724#answer_168899
  3 件のコメント
Image Analyst
Image Analyst 2015 年 2 月 23 日
Drag is a force in the opposite direction to acceleration. Remember Netwon's law, F=m*a. So you have -Drag/m as a negative acceleration, so add that to a, which will make a smaller. Unless your professor gave you some other formula...
Rick Rosson
Rick Rosson 2015 年 2 月 23 日
編集済み: Rick Rosson 2015 年 2 月 23 日
Not quite correct. Drag is a force in the opposite direction to velocity, not acceleration. The net acceleration may or may not be in the same direction as the velocity. And the component of the acceleration resulting from the drag will always point in the same direction as the component of the force resulting from the drag (as required by Newton's second law).

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by