The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Vector definition using variables
Replies: 4   Last Post: Dec 7, 2012 6:55 AM

Advanced Search

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

Posts: 18,038
Registered: 12/7/04
Re: Vector definition using variables
Posted: Dec 5, 2012 12:46 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Matt " <> wrote in message
> Hello guys,
> I am having the following problem when I want to use the following
> function :
> --------------
> tstep=0.1;
> final_time=30;
> vect1=0:tstep:final_time
> --------------
> So the vector produced should be 1x301 long. Now the problem is that my
> tstep value is defined like this :
> --------------
> tstep=((length(time)-1))/length(d)
> --------------
> Where time is a 1x301 vector so value for length(time) should be 301, and
> d is a 1x330 vector so the value for length(d) should be 330. Therefore
> the value for tstep should be (301-1)/330=0.909090
> When I put this above value manually into vect1, it gives me the correct
> vector that I am looking for, but I'm using the tstep value given by the
> calculation above (using the length function), it doesn't work. It gives
> me a 1x34 vector for example.

What do you expect the length of vect1 to be in this scenario? Seems to me
the tstep value for your second case is just over 9 times as large as the
step for your first case and the endpoints are the same, so the vector
should be approximately 1/9 the length. What is 301/9?

Did you intend for final_time to be related somehow to the values in the
time variable? That's not what you described.

Steve Lord
To contact Technical Support use the Contact Us link on

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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.