Matlab Coder does not properly execute/support mldivide (a.k.a "\") ?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
xavier soltner
le 27 Avr 2021
Réponse apportée : xavier soltner
le 29 Avr 2021
Hi,
I'm having trouble with Matlab Coder who seems to not properly execute the mldivide(a,b) function..
The code is supposed to calculate the misplacement of a workpiece position. The part I have trouble with is the following :
% construct vector and matrices, around current estimate of p, to have: dmes=V+M*pest => pest=M\(dmes-V)
V=d(pest)-pest(1)*dd_dx(pest)-pest(2)*dd_dy(pest)-pest(3)*dd_dtheta(pest);
M=[dd_dx(pest), dd_dy(pest), dd_dtheta(pest)];
fprintf("V1=%f V2=%f V3=%f\n",V(1),V(2),V(3));
fprintf("M11=%f M12=%f M13=%f\n",M(1,1),M(1,2),M(1,3));
fprintf("M21=%f M22=%f M23=%f\n",M(2,1),M(2,2),M(2,3));
fprintf("M31=%f M32=%f M33=%f\n",M(3,1),M(3,2),M(3,3));
% resolve for new value of pest
tempVar=(dmes-V);
pest=mldivide(M,tempVar);
%pest=M\(dmes-V);
fprintf("pest1=%f pest2=%f pest3=%f\n",pest(1),pest(2),pest(3));
When directly executing the code with Matlab I have the following output:
dmes1=0.000250 dmes2=-0.000360 dmes3=0.000156
V1=0.000000 V2=0.000000 V3=0.000000
M11=-0.707107 M12=0.707107 M13=19.996980
M21=-0.707107 M22=-0.707107 M23=19.996980
M31=1.000000 M32=0.000000 M33=20.000000
%execution of mldivide in matlab
pest1=0.000124 pest2=0.000431 pest3=0.000002
Wich give me the correct pest(=PositionEstimation) of the workpiece, but when I execute it in my C++ program I have the following :
dmes1=0.000250 dmes2=-0.000360 dmes3=0.000156
V1=0.000000 V2=0.000000 V3=0.000000
M11=-0.707107 M12=0.707107 M13=19.996980
M21=-0.707107 M22=-0.707107 M23=19.996980
M31=1.000000 M32=0.000000 M33=20.000000
%execution of mldivide in C++ programm
pest1=nan pest2=nan pest3=nan
Anyone know the reason for this to happen or any fix ?
Regards,
Xavier
1 commentaire
Ji Lee
le 28 Avr 2021
It seems like there is some amount of code missing from the snippet posted. Namely, the variables used on the first line of code (right-hand side of the assignment into V) look undefined. Would you be able to fill in the missing gap(s)?
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur MATLAB Coder dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!