From: Bruno Luong on
"Bryan Benson" <do.not.email(a)spam.com> wrote in message <hra188$ev7$1(a)fred.mathworks.com>...

>
> It gives me a 'too many elements' error message

Beware about the difference between

hypothenus = zeros(length(x))
hypothenus = zeros(numel(x))
hypothenus = zeros(100000)

and

hypothenus = zeros(1,length(x))
hypothenus = zeros(1,numel(x))
hypothenus = zeros(1,100000)
hypothenus = zeros(size(x))

Bruno
From: Bryan Benson on
"Roger Stafford" <ellieandrogerxyzzy(a)mindspring.com.invalid> wrote in message <hra0us$p6h$1(a)fred.mathworks.com>...
> "Bryan Benson" <do.not.email(a)spam.com> wrote in message <hr9u6p$kl3$1(a)fred.mathworks.com>...
> > ........
> > for i=1:length(t)
> > hypotenuse(i) = sqrt(x(i)^2 + y(i)^2);
> > end
> >
> > rawvelocity(1)=0;
> > for i=2:length(hypotenuse)
> > rawvelocity(i) = hypotenuse(i)-hypotenuse(i-1);
> > end
> > ........
> ------------------
> Bryan, your calculation of velocity looks entirely fallacious to me. If x(i) and y(i) are coordinates of absolute position, then your 'hypotenuse(i)' would be the distance from the coordinate origin at (0,0) to the point (x(i),y(i)). In that case hypotenuse(i)-hypotenuse(i-1) is *not* the distance traveled between time i-1 and time i. Far from it! Draw a triangle connecting the three points (0,0), (x(i-1),y(i-1)), and (x(i),y(i)). The distance traveled is the length of the side connecting the second two points, which is certainly not the same thing as the difference between the lengths of the other two sides!
>
> On the other hand if x and y represent differences in successive coordinates, you would want the velocity to be just this 'hypontenuse' not its successive differences.
>
> Either way the calculation is not correct as far as I can see.
>
> Roger Stafford

Hi Roger,

We're only interested in velocity away from the origin. But good eye!

Bruno: thank you! That removed the error message.
From: James Tursa on
Walter Roberson <roberson(a)hushmail.com> wrote in message <hr9vm1$ev8$1(a)canopus.cc.umanitoba.ca>...
>
> Note that if your values might be above 10^150 or below 10^(-150) then instead
> of using sqrt(x.^2 + y.^2) you should use hypot(x, y) which is an undocumented
> function that will be slower but will produce accurate answers without
> overflows or underflows from squaring the values.

hypot is documented, at least in later versions of MATLAB.

James Tursa
First  |  Prev  | 
Pages: 1 2
Prev: dct2 important
Next: using matlab as a solver