Horzcat Error in 3x3 matrix with multiplication of Matrices
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Torsten
el 31 de Ag. de 2023
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) ]
Respuesta aceptada
Voss
el 31 de Ag. de 2023
Editada: Voss
el 31 de Ag. de 2023
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 comentarios
Torsten
el 31 de Ag. de 2023
Editada: Torsten
el 31 de Ag. de 2023
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)
Más respuestas (1)
the cyclist
el 31 de Ag. de 2023
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 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!