Loaded quaternion but still cannot find slerp

After installing the Sensor Fusion toolbox, Matlab reopens. I used the following code:
q1 = quaternion([75,-20,-10],"eulerd","ZYZ","frame");
q2 = quaternion([-45,20,30],"eulerd","ZYZ","frame");
T = 0.5;
b = slerp(q1,q2,T);
But MATLAB returns error:
Unrecognized function or variable 'slerp'.
When I look it up, the only posts say quaternion must be loaded, and it is indeed loaded since I can see Quaternion objects for q1 and q2. Then, I also installed navigation toolbox, but the problem remains.

3 Kommentare

Can you show us what you see when you run all of the following commands? The last three are intended to make sure you're calling the quaternion function you think you are (and not one from a different toolbox) and to check what MATLAB thinks it should be calling when you call slerp.
q1 = quaternion([75,-20,-10],"eulerd","ZYZ","frame")
q1 = quaternion
0.83058 + 0.11732i - 0.12803j + 0.52914k
q2 = quaternion([-45,20,30],"eulerd","ZYZ","frame")
q2 = quaternion
0.97638 + 0.10571i + 0.13776j - 0.12854k
T = 0.5;
b = slerp(q1,q2,T);
which -all quaternion
/MATLAB/toolbox/shared/rotations/rotationslib/@quaternion/quaternion.m % quaternion constructor
whos q1 q2
Name Size Bytes Class Attributes q1 1x1 32 quaternion q2 1x1 32 quaternion
which -all slerp(q1,q2,T)
/MATLAB/toolbox/shared/rotations/rotationslib/+matlabshared/+rotations/+internal/@quaternionBase/slerp.m % quaternion method
q1 = quaternion([75,-20,-10],"eulerd","ZYZ","frame")
q2 = quaternion([-45,20,30],"eulerd","ZYZ","frame")
T = 0.5;
b = slerp(q1,q2,T);
which -all quaternion
whos q1 q2
which -all slerp(q1,q2,T)
q1 = quaternion
size: 1 x 3
Error using horzcat
Dimensions of arrays being concatenated are not consistent.
Error in quaternion/display (line 5)
d = [q.a(:),q.b(:),q.c(:),q.d(:)];
Error in quaternion/display (line 17)
display(q,'onlyShowQuaternions')
I installed another aerospace toolbox since then, and now this is the error, I can't even create the quaternion anymore. But I think you are correct. I have the MTEX library and the quaternion was created from MTEX instead of from the MATLAB toolboxes. Is there a way to specify which toolbox to use, or do I have to disable MTEX when I need to do this?
I disabled MTEX and now it works

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Zhangxi Feng
Zhangxi Feng am 16 Mai 2024

0 Stimmen

Thanks to @Steven Lord, I realized that another externally installed library, MTEX, is causing the issue. I disabled MTEX and now it is solved.

Weitere Antworten (0)

Kategorien

Produkte

Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by