Create multidimensional rotation matrix

3 次查看(过去 30 天)
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)];

采纳的回答

Matt J
Matt J 2023-3-24
编辑:Matt J 2023-3-24
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by