ODE to answer projectile question

조회 수: 12 (최근 30일)
Questioner
Questioner 2017년 3월 2일
댓글: Carlos Felipe Rengifo 2018년 7월 14일
Hello,
I am a student and very weak with matlab, I come accross this question about projectiles for matlab and I am having a really bad time solving it. Would appreciate if somebody could help my deadline is in a few days!
The S number is defined like this RandStream.setGlobalStream(RandStream('mt19937ar','seed',1403767)); S=rand(1);

답변 (1개)

Carlos Felipe Rengifo
Carlos Felipe Rengifo 2018년 7월 7일
I hope this will help you:
clc;
clear variables;
close all;
% Parameters of the model
S = rand(1);
M = 10;
B = 2;
g = 9.81;
a = deg2rad(35)*(1+0.2*S);
V0 = 28*(1+0.2*S);
% Dynamic model
% XDot = f(t,X), with X = [Vx,Vy,X,Y]
F = @(t,X) [-B/M*X(1); -g-B/M*X(2); X(1); X(2)];
% Initial conditions
X0 = [V0*cos(a); V0*sin(a); 0; 0];
% Numerical solution
[T,X] = ode45(F,[0,4],X0);
% Plots
subplot(2,2,1); plot(T,X(:,1)); title('Vx vs. Time'); grid on;
ylabel('Vel. [m/s]'); xlabel('Time [s]');
subplot(2,2,2); plot(T,X(:,2)); title('Vy vs. Time'); grid on;
ylabel('Vel. [m/s]'); xlabel('Time [s]');
subplot(2,2,3); plot(T,X(:,3)); title('X vs. Time'); grid on;
ylabel('Pos. [m]'); xlabel('Time [s]');
subplot(2,2,4); plot(T,X(:,4)); title('Y vs. Time'); grid on;
ylabel('Pos. [m]'); xlabel('Time [s]');
  댓글 수: 2
James Tursa
James Tursa 2018년 7월 7일
Please do not post complete solutions to homework problems.
Carlos Felipe Rengifo
Carlos Felipe Rengifo 2018년 7월 14일
I apologize for any inconvenience caused by my answer. I will be more careful next time.

댓글을 달려면 로그인하십시오.

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by