Effacer les filtres
Effacer les filtres

matlab code for Euler's method

1 vue (au cours des 30 derniers jours)
Mary Jeppson
Mary Jeppson le 26 Mai 2016
Commenté : Mary Jeppson le 27 Mai 2016
I have written this code for my class, but keep getting 'index exceeds matrix dimensions' can anyone tell me what's wrong with it?
%%Problem 1.9
%Use Euler's method to solve for the depth of a tank
A = 1250; %area in m^2
Q = 450; %m^3/d
h = .5; %step size
t = 0:h:10; % time in d
dydt = @(t) 3.*Q./A.*sin(t).^2-Q./A
y(1) = 0;
for k=1:length(t)-1
y(k+1) = y(k)+dydt(v(k))*h
end
[t' y']
I greatly appreciate the help.

Réponse acceptée

Walter Roberson
Walter Roberson le 26 Mai 2016
What is v ?
  1 commentaire
Mary Jeppson
Mary Jeppson le 27 Mai 2016
Thanks.. That was the problem.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by