How can I fix this error?
4 views (last 30 days)
Show older comments
theta=30
sign=(cosd (theta)/abs (cosd (theta)))
u=.8
R=12
c=5
y=8
Id=(.5*Md*R^2)
Mp=75
Mb=30
alpha=0
u=.8
L=6*R
a=[1 0 1 0 0 0 0 0 0 0 0; 0 1 0 1 0 0 0 0 0 0 0; 0 0 (-R*sind (theta)) (R*cosd (theta)) 0 0 0 0 0 0 1; 0 0 0 0 1 0 1 0 0 0 0; 0 0 0 0 0 1 0 1 0 0 0; 0 0 0 0 (-R*sind (theta)) (R*cosd (theta)) 0 0 0 0 0; 0 0 -1 0 -1 0 0 0 (4*abs (sign)) 0 0; 0 0 0 -1 0 -1 0 0 (-4*u*sign) 0 0; 0 0 -c (3*R) -c (-3*R) 0 0 (-4*(y-c)) 0 0; 0 0 0 0 0 0 0 0 (-u*sign) 1 0]
c=[0; Md*g; Id*alpha; 0; Md*g; Id*alpha; Mp*ax; Mp*y; 0; Mb*ab; Mb*g]
x=c/inv(a)
Trial>> x=c/inv(a)
Error using inv
Matrix must be square.
2 Comments
John D'Errico
on 12 Jun 2016
Writing c/inv(a) is wrong for several reasons, sufficiently so that I have no idea what you really want to solve. To start with,
- Md is undefined
- a is not square, so you cannot form the inverse matrix
- Since / will factor the matrix inv(a) and THEN try to do something similar to taking an inverse, you are essentially trying to form the inverse of the inverse of a.
I think you need to think about what you are trying to do. At least, explain it, because your code makes no sense.
Answers (1)
John D'Errico
on 12 Jun 2016
Edited: John D'Errico
on 12 Jun 2016
So x is a VECTOR, not a matrix.
You need to understand there will NOT be a unique solution. The matrix a is 10 by 11, so the problem is under-determined. There are infinitely many solutions to such a problem.
You can solve the problem A*x=c, for unknown vector x a:
x = a\c;
This will generate ONE solution, that has the property that at least one of the unknown elements in x will be zero.
Alternatively, you can use
x = pinv(a)*c;
This solution will have the property that it will have a minimum norm among all possible solutions.
And of course, you need to consider if there should be another row in the matrix a (and one more element in c). Such an under-determined problem may indicate that your problem is not formulated properly as written.
0 Comments
See Also
Categories
Find more on Linear Algebra in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!