Why is the inv function not working in this code (simple)

7 visualizaciones (últimos 30 días)
Delta
Delta el 1 de Oct. de 2019
Comentada: Delta el 1 de Oct. de 2019
m=[cos(-90*pi/180)-cos(30*pi/180) 1;cos(-135*pi/180)-cos(45*pi/180) 1; cos(-180*pi/180)-cos(70*pi/180) 1];
r=[cos(120*pi/180); cos(180*pi/180); cos(250*pi/180)];
k=inv(m)*r;a(1)= 1/k(1); a(3)=1/k(2);
t1=1/k(1)^2;t2=1/k(2)^2;t3=2*k(3)/k(1)*k(2));a(2)=(t1+t2+1-t3)^.5;
thank you!

Respuesta aceptada

James Tursa
James Tursa el 1 de Oct. de 2019
Editada: James Tursa el 1 de Oct. de 2019
Best to put commas in your matrix difinition so that the parser doesn't inadvertently combine things that you didn't want. E.g., (assuming you wanted a 3x3 instead of a 3x2 matrix result)
>> m=[cos(-90*pi/180)-cos(30*pi/180) 1;cos(-135*pi/180)-cos(45*pi/180) 1; cos(-180*pi/180)-cos(70*pi/180) 1]
m =
-0.8660 1.0000
-1.4142 1.0000
-1.3420 1.0000
>> m=[cos(-90*pi/180),-cos(30*pi/180), 1;cos(-135*pi/180),-cos(45*pi/180), 1; cos(-180*pi/180),-cos(70*pi/180), 1]
m =
0.0000 -0.8660 1.0000
-0.7071 -0.7071 1.0000
-1.0000 -0.3420 1.0000
That being said, this operation with inv( )
>> k=inv(m)*r
k =
1.3568
2.8907
2.0035
is better performed using the backslash operator:
>> k=m\r
k =
1.3568
2.8907
2.0035
You rarely need to use the inv( ) function in MATLAB.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by