matlab code for Euler's method

조회 수: 1 (최근 30일)
Mary Jeppson
Mary Jeppson 2016년 5월 26일
댓글: Mary Jeppson 2016년 5월 27일
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.

채택된 답변

Walter Roberson
Walter Roberson 2016년 5월 26일
What is v ?
  댓글 수: 1
Mary Jeppson
Mary Jeppson 2016년 5월 27일
Thanks.. That was the problem.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by