用MATLAB解决问题,需要代码

用MATLAB解答: 一个小球以水平速度vx从高度h处抛出,与地面碰撞后继续向前跳跃。假设小球在水平方向没有摩擦,在竖直方向碰撞后的速率与碰撞前的速率之比为k(k<1),称为反弹系数,作图画出小球的运动轨迹(解析法和数值法),并分析反弹系数k对轨迹的影响。如果考虑空气阻力与速率车成正比F=-av,小球的运动轨迹是会发生什么变化?
用代码块功能插入代码,请勿粘贴截图

你把物理运动计算公式贴出来,实现起来不难,几个函数的事

matlab 自带的 ballode 参考:

img


function ballode

%BALLODE  Run a demo of a bouncing ball.  
%   This is an example of repeated event location, where the initial
%   conditions are changed after each terminal event.  This demo computes ten
%   bounces with calls to ODE23.  The speed of the ball is attenuated by 0.9
%   after each bounce. The trajectory is plotted using the output function
%   ODEPLOT. 
%
%   See also ODE23, ODE45, ODESET, ODEPLOT, FUNCTION_HANDLE.

%   Mark W. Reichelt and Lawrence F. Shampine, 1/3/95
%   Copyright 1984-2004 The MathWorks, Inc.

tstart = 0;
tfinal = 30;
y0 = [0; 20];
refine = 4;
options = odeset('Events',@events,'OutputFcn',@odeplot,'OutputSel',1,...
                 'Refine',refine);

figure;
set(gca,'xlim',[0 30],'ylim',[0 25]);
box on
hold on;

tout = tstart;
yout = y0.';
teout = [];
yeout = [];
ieout = [];
for i = 1:10
  % Solve until the first terminal event.
  [t,y,te,ye,ie] = ode23(@f,[tstart tfinal],y0,options);
  if ~ishold
    hold on
  end
  % Accumulate output.  This could be passed out as output arguments.
  nt = length(t);
  tout = [tout; t(2:nt)];
  yout = [yout; y(2:nt,:)];
  teout = [teout; te];          % Events at tstart are never reported. 
  yeout = [yeout; ye];
  ieout = [ieout; ie];

  ud = get(gcf,'UserData');
  if ud.stop
    break;
  end
  
  % Set the new initial conditions, with .9 attenuation.
  y0(1) = 0;
  y0(2) = -.9*y(nt,2);

  % A good guess of a valid first timestep is the length of the last valid
  % timestep, so use it for faster computation.  'refine' is 4 by default.
  options = odeset(options,'InitialStep',t(nt)-t(nt-refine),...
                           'MaxStep',t(nt)-t(1));

  tstart = t(nt);
end

plot(teout,yeout(:,1),'ro')
xlabel('time');
ylabel('height');
title('Ball trajectory and the events');
hold off
odeplot([],[],'done');

% --------------------------------------------------------------------------

function dydt = f(t,y)
dydt = [y(2); -9.8];

% --------------------------------------------------------------------------

function [value,isterminal,direction] = events(t,y)
% Locate the time when height passes through zero in a decreasing direction
% and stop integration.  
value = y(1);     % detect height = 0
isterminal = 1;   % stop the integration
direction = -1;   % negative direction


matlab小球水平抛出,【原创】MATLAB中模拟小球上抛和反弹运动
https://blog.csdn.net/weixin_32512261/article/details/115828919