Prev: Problem with code
Next: MATLAB: code problem
From: Paso Sivro on 21 May 2010 20:46 Hello! Can somebody tell me where is the problme in the following code (timestep cant be increased). Thanx in advance! clear %function falling_apple g= 9.81; h(1,1)=10; v(1,1)=10; timestep=0.01; index=1; while (h(index)>0) v(index+1,1)=v(index,1)-g*timestep; h(index+1,1)=h(index,1)-v(index,1)*timestep; index=index+1; end figure(1); plot(v); xlabel('timestep'); ylabel ('v[m/s]'); figure(2); plot(h); xlabel('timesptep'); xlabel('h[m]'); return
From: John D'Errico on 21 May 2010 21:05 "Paso Sivro" <findsivro(a)gmail.com> wrote in message <ht79gc$ip0$1(a)fred.mathworks.com>... > Hello! > > Can somebody tell me where is the problme in the following code (timestep cant be increased). Thanx in advance! Sure it can be increased. timestep=1000000; Perhaps you have some reason for asking this question? Is this your homework assignment? John
From: Matt Fig on 21 May 2010 21:25 Your velocity is getting smaller as the apple falls. Is that what one would expect? Also, your height should decrease parabolically, not linearly. You may need a break statement for the case where the height becomes less than zero.
From: Paso Sivro on 21 May 2010 21:35 What do you write it in MATLAB break? "Matt Fig" <spamanon(a)yahoo.com> wrote in message <ht7bpi$dvq$1(a)fred.mathworks.com>... > Your velocity is getting smaller as the apple falls. Is that what one would expect? Also, your height should decrease parabolically, not linearly. You may need a break statement for the case where the height becomes less than zero.
From: Matt Fig on 21 May 2010 21:41 Look at the help for BREAK. >> help break
|
Pages: 1 Prev: Problem with code Next: MATLAB: code problem |