transformation of a rotary coordinate system to a static coordinate system

Hi all,
I need to transform rotary coordinate system to a static coordinate system. I found tranformation matrix, but i dont know how to write a for cycle for this. Tba= [cos(phi) -sin(phi); sin(phi) cos(phi)] - tranformation matrix
Rba=[Xb; Yb]; are values from rotary CS. Xb, Yb are 1251208x1 vector.
Result =Tba*Rba; - this should be result.
All values turn about 0,96 degree per step. (First value is turned by 0,96 degree, second one 0,96+0,96 and so on to 360). So i need to tranform every single number step by step by i+0,96 degree to 360 degree and 1251208 times whitch is dimension of a vector of values.
Can someone help please?
Thanks.

Answers (1)

There appears to be no simpler approach than iterating through all values and applying a rotation matrix with an incrementally increasing angle of 0.96 degrees per step. The implementation may be structured as follows:
It would look something like this:
% Preallocating for greater speed !
Xa = zeros(size(Xb));
Ya = zeros(size(Yb));
for i = 1:length(Xb)
    phi = i * 0.96;
    rad = deg2rad(phi);
    Tba = [cos(rad), -sin(rad); sin(rad), cos(rad)];
    Rba = [Xb(i); Yb(i)];
    Ra = Tba * Rba;
    Xa(i) = Ra(1);
    Ya(i) = Ra(2);
end
Hope this proves helpful

Categories

Find more on Language Fundamentals in Help Center and File Exchange

Products

Release

R2020b

Tags

Asked:

on 23 Feb 2022

Answered:

on 19 Jun 2025

Community Treasure Hunt

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

Start Hunting!