Borrar filtros
Borrar filtros

Unable to run pinv (Moore Penrose) , get errors

1 visualización (últimos 30 días)
Ken
Ken el 11 de Feb. de 2022
Comentada: Ken el 14 de Feb. de 2022
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 comentarios
Walter Roberson
Walter Roberson el 11 de Feb. de 2022
what is class(J_BF_inB)
Ken
Ken el 11 de Feb. de 2022
Sorry, I should have mentioned it:
J_BF_inB=@(alpha,beta,gama)[0,-cos(beta+gamma)-cos(beta),cos(alpha)*(cos(beta+gamma)+cos(beta)+1),
-sin(alpha)*(sin(beta+gamma)+sin(beta)),-sin(beta+gamma)*sin(alpha);...
sin(alpha)*(cos(beta+gamma)+cos(beta)+1),cos(alpha)*(sin(beta+gamma)+...
sin(beta)),sin(beta+gamma)*cos(alpha)];

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 12 de Feb. de 2022
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 comentarios
Walter Roberson
Walter Roberson el 14 de Feb. de 2022
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.
Ken
Ken el 14 de Feb. de 2022
Thanks. Main problem is my limited knowledge of Matlab, hence unable to fully comprehend your suggestions. I felt your suggestion where you outlined the steps and rationale was really good. Hence I tried to use it and then got the error about single/double. That was due to using pinv on the handle as you mentioned often. So, I would like to use that approach if somehow I could circumvent the handle issue. The 3X3 matrix does not have full rank, hence iterative solution is used.

Iniciar sesión para comentar.

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by