Can someone help with my code I know MATLAB well I want the code to run and print out a time and height graph.
3 次查看(过去 30 天)
显示 更早的评论
6 个评论
Image Analyst
2020-11-10
Attach your m-file with the paper clip icon. Or else just copy from MATLAB and paste back here in your reply, then highlight it and click the code icon.
回答(1 个)
Mathieu NOE
2020-11-10
so -- after several corrections, we hav something
see below
Also I noticed in the hand paper you have swapped the initial values for V1x and V1y
clc;
close all;
clear all;
%User Input
h_person_in = (51.3/12);% HEIGHT in inches times .75 then converted to feet
v1 = 10; %ft/s current velocity
theta_deg = 15; %degrees
e = .8; %coefficient of restitution
x = 6.10 % ft length of where i want the ball to land
g = 32.2 % ft/s^2
t =0 % starting time (initial conditions)
% v1y = v1*sin(theta_deg);
% v1x = v1*cos(theta_deg);
v1y = v1*sin(theta_deg*pi/180); %correction
v1x = v1*cos(theta_deg*pi/180); %correction
% v1y^2 == v1y^2+(2*-g*h_person_in)
v1y_squared = v1y^2+(2*g*h_person_in); % correction
v1y = sqrt(v1y_squared); % missing line
v2 = sqrt((e*v1y)^2+v1x);
% solve for t1 (second order equation)
% h_person_in = v1y*t1+(.5*g*t1^2)
% reorgainzed like : ax² + bx + c = 0
a = .5*g;
b = v1y;
c = - h_person_in;
% determinant : delta = b² -4*a*c
delta = b^2 -4*a*c;
% solution (positive) : sol = (-b+sqrt(delta)) / (2*a)
t1 = (-b+sqrt(delta)) / (2*a);
theta_deg2 = 180/pi*atan((e*v1y)/v1x); % correction
x1= v1x*t1;
x2= x-x1;
% tf= v1x/x2; % time cannot be velocity / distance it's the contrary
tf= x2/v1x; %
% display (example) in command window
disp([' time t1 is : ' num2str(t1) ' seconds']);
disp([' time tf is : ' num2str(tf) ' seconds']);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!