Create multidimensional rotation matrix

5 views (last 30 days)
I have two 1x541 column vectors: one for latitudes and one for longitudes.I want to create a 3d array rotation matrix where each iteration in the third dimension steps from 1 to 541 from the column vector. It should be a 3x3x541 array.
Here is what I have so far:
"aclon" and "aclat" are the 541x1 column vectors. "howbig" is just the length of the column vectors and used for matching the length of "aclon" and "aclat"
My code currently produces a 1623x3 matrix
Rm = [sin(aclon) cos(aclon) zeros(howbig,1); -sin(aclat).*cos(aclon) sin(aclat).*sin(aclon) cos(aclat); cos(aclat).*cos(aclon) cos(aclat).*sin(aclon) sin(aclat)];

Accepted Answer

Matt J
Matt J on 24 Mar 2023
Edited: Matt J on 24 Mar 2023
howbig=541;
[aclon,aclat]=deal(rand(howbig,1)); %fake input data
aclon=reshape(aclon,1,1,[]);
aclat=reshape(aclat,1,1,[]);
Rm = [sin(aclon) cos(aclon) 0*aclat;
-sin(aclat).*cos(aclon) sin(aclat).*sin(aclon) cos(aclat);
cos(aclat).*cos(aclon) cos(aclat).*sin(aclon) sin(aclat)];
whos Rm
Name Size Bytes Class Attributes Rm 3x3x541 38952 double

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!