Info

This question is closed. Reopen it to edit or answer.

I am having trouble animating the plot of my ode

1 view (last 30 days)
David
David on 3 Apr 2014
Closed: MATLAB Answer Bot on 20 Aug 2021
I am having trouble plotting this ode because the input parameters can vary so much, so setting up the axis has to be based on the inputs some how. The program is designed to show the projectile of a sphere, however for modeling purposes everything is non-diminsonialized. It is important to understand this needs to work with any weight, and any velocity whether it is positive or negative. The graph also needs to be animated and have a trail of where the sphere has been.
This is the code for the program:
function ParaPower %Group: Para Power
clear all; clc;
%Call User Inputs prompt = {'Enter sphere mass, in kg:','Enter sphere radius, in m:','Enter initial horizontal velocity of sphere in m/s:','Enter initial vertical velocity of sphere in m/s:','Enter wind velocity in m/s:'};
dlg_title = 'User Inputs';
def = {'5','1','10','10','15'};
params = inputdlg(prompt, dlg_title, 1, def);
user_inputs = str2double(params);
Mass_sphere = user_inputs(1); Radius_sphere = user_inputs(2); U1 = user_inputs(3); V1 = user_inputs(4); U = user_inputs(5);
%Constants: g = 9.81;
Visc_air = 0.0000179; %dynamic for 15 deg. C; from Wiley Ut = U*(g*Radius_sphere)^-.5; %non-dim wind velocity x Vt = 0*(g*Radius_sphere)^-.5; %non-dim wind velocity y Us = U1*(g*Radius_sphere)^-.5; %non-dim sphere velocity x Vs = V1*(g*Radius_sphere)^-.5; %non-dim sphere velocity y Roh_sphere = ((Mass_sphere/g)/(4*pi/3)*(Radius_sphere)^3); %density of sphere Re = (Roh_sphere*2*Radius_sphere)/Visc_air; %reynolds number Cd = 24/Re; Roh_air = 1.23; %air density for 15 deg. C; from Wiley A = Cd*3*Roh_air/(8*Roh_sphere); %grouped for simplification
times = linspace(0,20,100); intvals = [0,Us,0,Vs];
[t,x] = ode45(@func, times, intvals, [], A, Us, Vs); function f= func(t, x, A, U, V)
f(1) = x(2); f(2) = A*(sqrt((Ut-x(2))^2+(Vt-x(4))^2))*(Ut-x(2)); f(3) = x(4); f(4) = A*(sqrt((Ut-x(2))^2+(Vt-x(4))^2))*(Vt-x(4))-1; f = f';
end
end
Thank you!!!

Answers (0)

Community Treasure Hunt

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

Start Hunting!