How can I make a script perform calculations across multiple columns?

Hi all,
I've written a very simple script that calculates an angle from x,y coordinates located on an excel spreadsheet. The spreadsheet has time measurements in the first column, followed by x coordinates on the second column and y coordinates in the third. The script works great for this but I would like it to perform these calculations on a spreadsheet that may have for example, time on the first, x and y coordinates on the second and third respectively and subsequently have multiple sets of coordinates across different columns.
If anyone has any ideas on where to start or point me in the right direction I'd be extremely grateful.
Thank you

 Accepted Answer

Read the spreadsheet into an array (I'll call it x for simplicity)...
x=xlsread(...
ang=bsxfun(@atan2,x(:,3:2:end),x(:,2:2:end));
Result is in radian, use atan2d for degrees...

More Answers (0)

Categories

Asked:

pm4
on 9 May 2015

Edited:

dpb
on 10 May 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!