Horzcat Error in 3x3 matrix with multiplication of Matrices
1 回表示 (過去 30 日間)
古いコメントを表示
I am attempting to write this 3x3 matrix :
NED=[ -sin(Latty).*cos(Lonny) -sin(Latty).*sin(Lonny) cos(Latty) ; -sin(Lonny) cos(Lonny) 0 ; -cos(Latty).*cos(Lonny) -cos(Latty).*sin(Lonny) -sin(Latty) ];
I am recieving this error
Error using horzcat
Dimensions of arrays being concatenated are not consistent.
Error in xlxstomat (line 87)
NED=[ -sin(Latty).*cos(Lonny) -sin(Latty).*sin(Lonny) cos(Latty) ; -sin(Lonny) cos(Lonny) 0 ; -cos(Latty).*cos(Lonny) -cos(Latty).*sin(Lonny) -sin(Latty) ];
2 件のコメント
Torsten
2023 年 8 月 31 日
Works for me:
Latty = pi/6;
Lonny = pi/4;
NED=[ -sin(Latty).*cos(Lonny) -sin(Latty).*sin(Lonny) cos(Latty) ; -sin(Lonny) cos(Lonny) 0 ; -cos(Latty).*cos(Lonny) -cos(Latty).*sin(Lonny) -sin(Latty) ]
採用された回答
Voss
2023 年 8 月 31 日
編集済み: Voss
2023 年 8 月 31 日
You've got the scalar zero in there causing the problem. Replace that scalar zero with a vector of zeros the same size as Latty and Lonny.
The result NED will be 186x3.
Latty = [
38
39
37
40
39
36
39
39
38
40
35
37
38
40
40
37
36
36
39
36
40
35
39
35
39
39
35
38
39
38
37
36
35
37
39
40
36
39
39
38
38
36
36
38
36
36
38
35
40
36
36
36
36
37
38
39
36
35
38
40
36
32];
Lonny = [
-117
-88
-112
-76
-110
-102
-88
-105
-88
-81
-84
-83
-118
-79
-96
-117
-106
-95
-83
-102
-78
-84
-91
-75
-75
-93
-98
-104
-108
-88
-80
-105
-86
-107
-106
-80
-110
-94
-107
-76
-104
-105
-104
-108
-96
-87
-117
-95
-102
-88
-91
-86
-80
-109
-99
-78
-108
-113
-88
-93
-102
0];
NED=[ -sin(Latty).*cos(Lonny) -sin(Latty).*sin(Lonny) cos(Latty) ; -sin(Lonny) cos(Lonny) zeros(size(Lonny)) ; -cos(Latty).*cos(Lonny) -cos(Latty).*sin(Lonny) -sin(Latty) ]
4 件のコメント
Torsten
2023 年 8 月 31 日
編集済み: Torsten
2023 年 8 月 31 日
Although the answer has been accepted, I think the aim was that each pair [Latty(i),Lonny(i)] should generate its own 3x3 matrix (after converting Latty and Lonny from degrees to radians):
Latty = [
38
39
37
40
39
36
39
39
38
40
35
37
38
40
40
37
36
36
39
36
40
35
39
35
39
39
35
38
39
38
37
36
35
37
39
40
36
39
39
38
38
36
36
38
36
36
38
35
40
36
36
36
36
37
38
39
36
35
38
40
36
32];
Lonny = [
-117
-88
-112
-76
-110
-102
-88
-105
-88
-81
-84
-83
-118
-79
-96
-117
-106
-95
-83
-102
-78
-84
-91
-75
-75
-93
-98
-104
-108
-88
-80
-105
-86
-107
-106
-80
-110
-94
-107
-76
-104
-105
-104
-108
-96
-87
-117
-95
-102
-88
-91
-86
-80
-109
-99
-78
-108
-113
-88
-93
-102
0];
N = numel(Latty);
Latty = deg2rad(Latty);
Lonny = deg2rad(Lonny);
NED = arrayfun(@(Latty,Lonny)[ -sin(Latty).*cos(Lonny) -sin(Latty).*sin(Lonny) cos(Latty) ; -sin(Lonny) cos(Lonny) 0 ; -cos(Latty).*cos(Lonny) -cos(Latty).*sin(Lonny) -sin(Latty) ],Latty,Lonny,'UniformOutput',0)
その他の回答 (1 件)
the cyclist
2023 年 8 月 31 日
There is nothing inherently wrong with the matrix you specified (as you can see from the code below).
You'll need to share more information. Can you upload a code snippet and data that will allow us to run the code and reproduce the error? (You can use the paper clip icon in the INSERT section of the toolbar to attach files.)
Please don't just share a description of what is going on.
Latty = pi/3;
Lonny = pi/7;
NED=[ -sin(Latty).*cos(Lonny) -sin(Latty).*sin(Lonny) cos(Latty) ;
-sin(Lonny) cos(Lonny) 0 ;
-cos(Latty).*cos(Lonny) -cos(Latty).*sin(Lonny) -sin(Latty)]
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!