On Sep 11, 3:53 am, "Z A" <nospamrekabi...@yahoo.ca> wrote:
> Sorry, but I had to take the transpose and then apply d1=sqrt((x(:,2)x(:,1)).^2+(y(:,2)y(:,1)).^2); etc... for the others: d2=sqrt((x(:,3)x(:,2)).^2+(y(:,3)y(:,2)).^2); d1=sqrt((x(:,4)x(:,3)).^2+(y(:,4)y(:,3)).^2). How do I write a simple script that does exactly that for those columns without first taking the transpose of x and y then applying the above equations?
>
> Much appreciated!
>
> "Z A" <nospamrekabi...@yahoo.ca> wrote in message <j4g0qg$d7...@newscl01ah.mathworks.com>...
> > Hello all,
>
> > I need some help in running a simple loop, as you can I am having problems!
> > Consider the following:
> > x y
> > 29.82 18.737
> > 29.761 18.601
> > 29.776 18.624
> > 29.782 18.578
> > 29.678 18.62
> > 29.757 18.556
> > 29.757 18.59
> > 29.738 18.635
> > 29.741 18.656
> > 29.729 18.646
> > 29.774 18.633
> > 29.731 18.592
> > 29.676 18.736
> > 29.718 18.795
> > 29.707 18.821
> > 29.706 18.855
> > 29.73 18.928
> > 29.678 18.948
> > 29.695 18.874
>
> > I want to find the displacement between each interval so something like
> > d1=sqrt((x.'(:,2)x.'(:,1)).^2+(y.'(:,2)y.'(:,1)).^2);
> > so for that case d1=0.14825. How do I write it in such a way that I can generate all? So next one would be d2=sqrt((x.'(:,3)x.'(:,2)).^2+(y.'(:,3)y.'(:,2)).^2); d1=sqrt((x.'(:,4)x.'(:,3)).^2+(y.'(:,4)y.'(:,3)).^2); etc...Rather than doing it individually! As you can see I took the transpose of x and y, is there a way where I don't need to do that as they are columns?
>
> > I appreciate the assistance!
dx=diff(x);
dy=diff(y);
ds=abs(dx+i*dy);
