필터 지우기
필터 지우기

Can someone help with my code I know MATLAB well I want the code to run and print out a time and height graph.

조회 수: 1 (최근 30일)
  댓글 수: 6
Honore Lopaka
Honore Lopaka 2020년 11월 10일
i want to do that in matlab i can solve it by hand i just dont know how to solve it using matlab and then print out h and t graph
Image Analyst
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
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']);

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by