Unable to run pinv (Moore Penrose) , get errors
1 次查看(过去 30 天)
显示 更早的评论
Tried the following script:
r0=[0,0,0];
dq=double(pinv(J_BF_inB)*(rGoal-r0));
dq=double(subs(dq,[alpha,beta,gamma],[0,0.52,1.04]));
q=q0;
for n=1:10
q=q+dq;
end
I get the following errors:
Error using svd
First input must be single or double.
Error in pinv (line 18)
[U,s,V] = svd(A,'econ');
Error in solution (line 24)
dq=double(pinv(J_BF_inB)*(rGoal-r0));
2 个评论
回答(1 个)
Walter Roberson
2022-2-12
You cannot take the pseudo-inverse of a function handle.
If you were to construct a symbolic array you might be able to pinv() that, but you would not be able to double() the results.
Are you expecting that the 3x3 matrix might not have full rank? If full rank is expected then this would look more like a job for the \ operator
12 个评论
Walter Roberson
2022-2-14
It helps solve your problem by pointing out where you went wrong on constructing the matrix.
It continues from there in stating that if you put in an arbitrary value for the 2nd or 3rd element of the middle row of the matrix (the one that is missing an element) then you get a singularity when you substitute alpha = 0, which makes it less likely (but not impossible) that the missing element is in the second or third position.
It then shows that if you put an arbitrary value as the first element of the second row, so that you can get out a 3 x 3 matrix, then you can calculate pinv(J_BF_inB)*(rGoal-r0) and then substitute in alpha, beta, gamma values .
How does it help you solve your overall question? Well it helps you debug the problem and shows you the kind of operations that can be done.
Does it solve the overall problem? Certainly not. As I have been explaining to you, your approach is wrong. Over in https://www.mathworks.com/matlabcentral/answers/1648515-unable-to-run-pinv-moore-penrose-with-accuracy-limit#answer_895320 I described the steps you need to take.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Descriptive Statistics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!