Given the following relations and pseudocode, develop a numerical solution which will determine the time it takes the ball to hit the ground given certain parameters ...
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Madeleine
el 23 de Abr. de 2014
Respondida: Image Analyst
el 23 de Abr. de 2014
Question continued ... then ... instead of just finding out how long it takes for the ball to hit the ground, plot velocity and displacement against time (label axes appropriately). Also consider making this a general function which can accept any inputs and test any cases.
These are the given relations
a = ((-k)/m)*(vo.^2) + g ;
a1 = (v-vo)/t ;
v = (s-so)/t ;
So far I've done what's below and I need help finishing it and fixing it up at my level of knowledge. Someone please help
clc;
clear;
%Given Variables
vo = 0;
so = 0;
ao = 0;
g = 9.81;
m = 10;
k = 5;
t = 7;
height = 5;
Total_Time = 0;
counter = 1;
%Calulate unknown variables of V2 and S2
while height > 0
v(counter) = (g - ((k/m)* (vo.^2)))*t + v(counter-1);
s(counter) = v*t + s(counter-1);
height = height - s;
Total_Time = Total_Time + t;
counter = counter + 1;
end
plot(s,v)
hold all;
set(gca, 'ylim', [0, 50]);
set(gca, 'ytick', 0:5:50) ;
set(gca, 'xlim',[0,50]);
set(gca,'xtick', 0:5:50);
xlabel('Velocity');
ylabel('Displacement');
title('Ball falling from a height of 5m');
disp('The final velocity ... final displacement ... and Total Time is: ')
disp(v);
disp(s);
disp(Total_Time);
0 comentarios
Respuesta aceptada
Image Analyst
el 23 de Abr. de 2014
Make your script into two functions, like this, all in one m-file called homework1.m:
function homework1
[out1, out2] = BallDrop(input1, input2); % Call BallDrop
% Define BallDrop
function [out1, out2] = BallDrop(in1, in2)
out1 = whatever;
out2 = blahblah;
0 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!