Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Why are my lengths not equal?
Replies: 1   Last Post: Sep 26, 2013 7:57 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
David

Posts: 1
Registered: 9/26/13
Why are my lengths not equal?
Posted: Sep 26, 2013 7:28 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.