Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.


David
Posts:
1
Registered:
9/26/13


Why are my lengths not equal?
Posted:
Sep 26, 2013 7:28 PM


I am trying to develop a plot of four approximations and compare them to each other on the same plot using delta t = 4,2,1,0.5. I am just doing one for dt = 1 to write and then will add the others in once I got it working. When I run my code, I get an error when it goes to plot that says the length of (t) and the length of (Y) are not equal. I am really not sure how to fix it.
dt = [ 1 ]; tend = 10; t = 1:dt:tend; g = 9.8; Y(1) = 0; Vy(1) = 100; for i = 1:length(dt) for n = 1:length ((t)1)
Y(n+1) = Vy(n) * dt + Y(n) Vy(n+1) = Vy(n)  g * dt end end length(Y) length(t) plot(t,Y)
I put length in there so I could see exactly how long they were and Y is always 1 more element longer than t no matter what values I use



