Im trying to write code for a vertically falling cannonball, i keep getting an error could "Undefined function 'function name' for input arguments of type 'double'. Can anyone help me out?
Afficher commentaires plus anciens
function [v,vterm] = Student(m,d,T)
% A funuction to deterined a vertically falling cannonball, while being
% effected by drag
% Various Constant
cd = 0.47; % drag coefficient for a sphere
rho = 1.2; % density of air
g = 9.81; % gravitational constant
dt = 0.1; % Time step
v = 0; % Vertically falling cannonball, released from rest
for t = 0:dt:T
a = ((cd*rho*(pi*d^2))/2*m)-g ;
v = v(t-1) + a(t)*dt ;
hold on;
plot (t,v,'.');
end
Fnet = cd*0.5*rho*(v(t)^2)*(pi*d^2);
if Fnet == 0
vterm = sqrt(2*m*g/rho*(pi*d^2)*cd);
end
The code I used to call this function is as followed
[v,vterm] = Student(5,2,20)
and the error message that was returned to me was:
Undefined function 'Student' for input arguments of type 'double'.

%
4 commentaires
Dominic Gladdish
le 27 Jan 2016
Image Analyst
le 27 Jan 2016
That's not error I get. I can call the function problem - it's inside it where there's an error. I get that it doesn't know about v(-1) which is exactly what Walter told you about. Did you not see his answer about how to correct the code?
Dominic Gladdish
le 27 Jan 2016
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!