Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
dpb
Posts:
6,693
Registered:
6/7/07
|
|
Re: Vector definition using variables
Posted:
Dec 5, 2012 2:08 PM
|
|
On 12/5/2012 12:14 PM, Matt wrote: > Thank you for your answer Steven. > > I would expect the value of vect1 to be 1x330. > > What I don't understand is that using the tstep formula, it gives me > something like 0.9 (300/330). > > My problem is that I have defined a final_time value to top the > simulation. But it happens that the value of d for example has more > columns than the vector time. For example d can be 1x400 and time still > stays 1x301. > > So I need to "rescale" the vector time, and that's why I want to use a > different time step, so both vectors can have the same length and can be > plotted together.
Well the problem w/ the above ratio is it is simply the ratio of the two vector lengths but not scaled by the time span (either based on the full length or that of the initial vect1). So, you computed a ratio of two lengths but didn't adjust the dT to go along with it.
>> tstep=0.1;f_time=30;vect1=0:tstep:f_time; >> tstep=tstep*300/330; >> vect2=0:tstep:f_time; >> length(vect2) ans = 331 >>
You might look at
doc linspace
--
|
|
|
|